janicefool
New Member
- Joined
- Sep 23, 2020
- Messages
- 9
- Office Version
- 2016
- Platform
- Windows
HI i want to transfer my data from userform to excel template for data entry.
Here's my code for a command button. Not sure why but i got this Compile Error message. Please advise.
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim iRow As Long
Set ws = Worksheets("Formulate Data")
'find first empty row in database
iRow = ws.Cells.Find(what:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
With ws
.Cells(iRow, 1).Value = Me.Label1.Value
.Cells(iRow, 2).Value = Me.Label2.Value
.Cells(iRow, 3).Value = Me.Label3.Value
.Cells(iRow, 4).Value = Me.Label4.Value
End With
'clear the data
Me.Label1.Value = " "
Me.Label2.Value = " "
Me.Label3.Value = " "
Me.Label4.Value = " "
End Sub
Here's my code for a command button. Not sure why but i got this Compile Error message. Please advise.
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim iRow As Long
Set ws = Worksheets("Formulate Data")
'find first empty row in database
iRow = ws.Cells.Find(what:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
With ws
.Cells(iRow, 1).Value = Me.Label1.Value
.Cells(iRow, 2).Value = Me.Label2.Value
.Cells(iRow, 3).Value = Me.Label3.Value
.Cells(iRow, 4).Value = Me.Label4.Value
End With
'clear the data
Me.Label1.Value = " "
Me.Label2.Value = " "
Me.Label3.Value = " "
Me.Label4.Value = " "
End Sub