Help editing next row with userform

FindingMyself

New Member
Joined
Jun 27, 2011
Messages
19
So here is my code,


Private Sub CommandButton1_Click()
Sheets("PM Checklist").Range("A2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = cboDay.Text & cboMonth.Text & cboYear.Text
Sheets("PM Checklist").Range("B2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = cboPMType.Text
Sheets("PM Checklist").Range("C2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = cboEquipment.Text
Sheets("PM Checklist").Range("D2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = txtSpecs.Text
Sheets("PM Checklist").Range("E2").End(xlDown).Offset(1, 0).Select
ActiveCell.Value = txtValue.Text & cboUnits.Text
End Sub


What I need to do is have my command button fill in a row of values with the values from my various dropbox and textbox and then move to the next row. I'm getting an error code with the above though :(

Here's a picture if it will help.
unledqzo.png
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to the board.

I think it would also have helped if you had told us specifically what the error code was.
 
Upvote 0
Welcome to the board.

I think it would also have helped if you had told us specifically what the error code was.
Thanks for the welcome ;)

I get a 'Run-time error 1004: Application-defined or object-defined error' every time I run the userform and click the command button. :(
 
Upvote 0
Try Below code

Code:
Private Sub CommandButton1_Click()
    Dim rngLastCell         As Range
    With ThisWorkbook.Worksheets("PM Checklist")
        Set rngLastCell = .Range("A" & Rows.Count).End(xlUp)
        rngLastCell.Offset(1, 0).Value = cboDay.Text & cboMonth.Text & cboYear.Text
        rngLastCell.Offset(1, 1).Value = cboPMType.Text
        rngLastCell.Offset(1, 2).Value = cboEquipment.Text
        rngLastCell.Offset(1, 3).Value = txtSpecs.Text
        rngLastCell.Offset(1, 4).Value = txtValue.Text & cboUnits.Text
    
    End With
    
End Sub
 
Upvote 0
Try Below code

Code:
Private Sub CommandButton1_Click()
    Dim rngLastCell         As Range
    With ThisWorkbook.Worksheets("PM Checklist")
        Set rngLastCell = .Range("A" & Rows.Count).End(xlUp)
        rngLastCell.Offset(1, 0).Value = cboDay.Text & cboMonth.Text & cboYear.Text
        rngLastCell.Offset(1, 1).Value = cboPMType.Text
        rngLastCell.Offset(1, 2).Value = cboEquipment.Text
        rngLastCell.Offset(1, 3).Value = txtSpecs.Text
        rngLastCell.Offset(1, 4).Value = txtValue.Text & cboUnits.Text
    
    End With
    
End Sub

It worked!
You've just saved me, you don't know how grateful I am. :biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,841
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top