georgefreight
New Member
- Joined
- Sep 21, 2015
- Messages
- 15
Hi
I've been adapting a userform I found online, however it is based on creating and filling in a new row each time. I need to change it so it always fills in the same cells then I have another macro to save it as a pdf to send to the customer.
Just trying to make it nice and simple so there is continuity in what is filled out and sent.
In trying to change it I've created errors which hasen't helped. The full code is below but I believe the problem are these 2 lines
Set ws = Worksheets("Sheet1")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
I wanted to set irow to be fixed as C4 and then I believe the rest of the code should fill in the cells appropriately from there (fingers crossed!)
Any and all help appreciated
I've been adapting a userform I found online, however it is based on creating and filling in a new row each time. I need to change it so it always fills in the same cells then I have another macro to save it as a pdf to send to the customer.
Just trying to make it nice and simple so there is continuity in what is filled out and sent.
In trying to change it I've created errors which hasen't helped. The full code is below but I believe the problem are these 2 lines
Set ws = Worksheets("Sheet1")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
I wanted to set irow to be fixed as C4 and then I believe the rest of the code should fill in the cells appropriately from there (fingers crossed!)
Any and all help appreciated
Code:
Private Sub cmdAdd_Click()
'Copy input values to sheet.
Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(1, 1).Value = Me.txtcompany.Value
.Cells(2, 1).Value = Me.txtcountry.Value
.Cells(3, 1).Value = Me.txtport.Value
.Cells(4, 1).Value = Me.txtterms.Value
.Cells(9, 5).Value = Me.txtsize.Value
.Cells(27, 5).Value = Me.txtcost.Value
.Cells(28, 5).Value = Me.txtline.Value
.Cells(31, 5).Value = Me.txtfreq.Value
End With
'Clear input controls.
Me.txtcompany.Value = ""
Me.txtcountry.Value = ""
Me.txtport.Value = ""
Me.txtterms.Value = ""
Me.txtsize.Value = ""
Me.txtcost.Value = "£"
Me.txtline.Value = ""
Me.txtfreq.Value = ""
End Sub
Private Sub CmdClose_Click()
'Close UserForm.
Unload Me
End Sub