Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

748
Visualizações
How to transform excel VBA code into Javascript for Google Sheets?

everyone. I need to change a code that I created in VBA to javascript and put it into Google Sheets. Does anyone know how I can do this? The code is below

Sub Influencers_automacao()
  Sheets(1).Activate
  Range("A1").Select
  Selection.End(xlDown).Select
  k = Selection.Row
  For t = 2 To Sheets.Count
    j = 2
    For i = 2 To k
      If Sheets(1).Cells(i, 1) = Sheets(t).Name Then
        Sheets(t).Cells(j, 1) = Sheets(1).Cells(i, 2)
        Sheets(t).Cells(j, 2) = Sheets(1).Cells(i, 3)
        j = j + 1
      End If
    Next
  Next
End Sub
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

I'm afraid the answer is that you have to learn javascript and the google sheets object model, or at least enough of it to figure out how to do the same things in js that you're doing in VBA.

However, you can try using the macro converter, and your existing VBA is pretty simple so it might work without alterations, but you might have to tweak it. Let me know if this works, or if you encounter errors with the converted code and we can try to work through them.

https://developers.google.com/apps-script/guides/macro-converter/convert-files

about 4 years ago · Santiago Gelvez Relatório

0

Try

function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var output = []
  ss.getSheets().forEach(function (sh, i) {
    if (i > 0) output.push([
      sh.getName(), sh.getRange('A1').getValue(), sh.getRange('B1').getValue()
    ])
  })
  ss.getSheets()[0].getRange(2, 1, output.length, output[0].length).setValues(output)
}

change A1, B1 as necessary

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda