Hello, I have this userform:
this is the sheet where the code works as I press one of the cells in the range. A2:A27
The code I have on that "Jan" sheet with the cells range for it to work.
Userform button code:
I'd like to adapt this code and userform to work on the sheets "Jan", "Fev" and "Mar".. (12 months in total) and all the data will be in the same cell range wich is A7:A27 for every one of those 12 sheets. The data will be different on each sheet.
But I need this to work from a button on the "Escalas" sheet.
I tried
and it works but I get error 13 type mismatch
Ex: One button on the sheet "Escalas" loads the userform and inserts the data on the A7:A27 range on sheet "Jan".
Another button on the same "Escalas" sheet loads the userform but inserts the data on range A7:A27 but for sheet "Fev"
the same for the other 10 months.
Sample file just in case anyone wants to see it.
http://s000.tinyupload.com/index.php?file_id=11610863767953451163
Best regards,
eLy
this is the sheet where the code works as I press one of the cells in the range. A2:A27
The code I have on that "Jan" sheet with the cells range for it to work.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("A2:A27")) Is Nothing Then
UserForm1.tbNumero = Cells(Target.Row, 2)
UserForm1.tbNome = Cells(Target.Row, 3)
UserForm1.tbTelefone = Cells(Target.Row, 4)
UserForm1.tbTelemovel = Cells(Target.Row, 5)
UserForm1.tbEmail = Cells(Target.Row, 6)
UserForm1.lblRow = Target.Row
UserForm1.Show
End If
End Sub
Userform button code:
Code:
Private Sub CommandButton1_Click()Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Jan")
x = Me.lblRow 'current row
ws.Cells(x, 2) = Me.tbNumero
ws.Cells(x, 3) = Me.tbNome
ws.Cells(x, 4) = Me.tbTelefone
ws.Cells(x, 5) = Me.tbTelemovel
ws.Cells(x, 6) = Me.tbEmail
Me.Hide
End Sub
I'd like to adapt this code and userform to work on the sheets "Jan", "Fev" and "Mar".. (12 months in total) and all the data will be in the same cell range wich is A7:A27 for every one of those 12 sheets. The data will be different on each sheet.
But I need this to work from a button on the "Escalas" sheet.
I tried
Code:
userform1.show
Ex: One button on the sheet "Escalas" loads the userform and inserts the data on the A7:A27 range on sheet "Jan".
Another button on the same "Escalas" sheet loads the userform but inserts the data on range A7:A27 but for sheet "Fev"
the same for the other 10 months.
Sample file just in case anyone wants to see it.
http://s000.tinyupload.com/index.php?file_id=11610863767953451163
Best regards,
eLy