Good,
I have this VBA code and I needed to build a Javascript for Google Docs that does the same thing. Is it possible to convert VBA to Javascript?
Thank you.
Private Sub CommandButton1_Click()
Dim F1 As Worksheet
Dim intervalo As Range
Dim LastRow As Long
'Declara a Planilha pelo nome
Set F1 = ThisWorkbook.Worksheets("Folha1")
'Última Linha
LastRow = F1.Cells(F1.Rows.Count, "A").End(xlUp).Row
Set intervalo = F1.Range("A2:A" & LastRow)
'Caso não encontre TextBox2
If TextBox2 = "" Then
MsgBox "Insira o nº da ficha a consultar."
'Se os campos de TextBox estiverem preenchidos
ElseIf TextBox2 > "" And TextBox1 > "" Then
'Realiza a procura
With intervalo
Set cellFound = .Find(TextBox1, LookIn:=xlValues)
If Not cellFound Is Nothing Then
FirstAddress = cellFound.Address
Do
'Realiza Ação após encontrar, faz offset de uma coluna para direita e segue o hyperlink. Então após encontrar na Coluna A, segue o hyperlink da coluna B.
cellFound.Offset(0, 1).Hyperlinks(1).Follow
Set cellFound = .FindNext(cellFound)
Loop While Not cellFound Is Nothing And cellFound.Address <> FirstAddress
End If
End With
End If
TextBox2.SetFocus
End Sub
Private Sub TextBox1_Change()
Dim intervalo As Range
Dim texto As String
Dim codigo As Integer
Dim pesquisa
Dim mensagem
Dim F1 As Worksheet
Set F1 = ThisWorkbook.Worksheets("Folha1")
LastRow = F1.Cells(F1.Rows.Count, "A").End(xlUp).Row
On Error Resume Next
codigo = TextBox1.Text
Set intervalo = F1.Range("A2:B" & LastRow)
pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 2, False)
TextBox2.Text = pesquisa
End Sub
'Private Sub UserForm_Terminate()
'ActiveWorkbook.Close Savechanges:=False
'End Sub