Editing an Entire Row

FindingMyself

New Member
Joined
Jun 27, 2011
Messages
19
So this is what I have right now,

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

It basicly fills the next available row with the values obtained from my userform. I also created a button to move between the previous and next cells which functions around Selection.Offset(1, 0).Select

Is there a way that I can edit an entire row that the currently active cell is in? I'd like to be able to replace the values with the ones from the userform, sort of like an edit button.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Untested, but maybe this would suffice because your active cell is presumably in ThisWorkbook already, on the sheet you plan to edit:


Code:
Private Sub CommandButton1_Click()
Dim myRow as Long
myRow = activecell.Row
cells(myRow, 1).Value = cboDay.Text & cboMonth.Text & cboYear.Text
cells(myRow, 2).Value = cboPMType.Text
cells(myRow, 3).Value = cboEquipment.Text
cells(myRow, 4).Value = txtSpecs.Text
cells(myRow, 5).Value = txtValue.Text & "|" & cboUnits.Text
End Sub

You might also be able to get away with this:

Code:
Private Sub CommandButton1_Click()
Dim myRow As Long
myRow = ActiveCell.Row
Range(Cells(myRow, 1), Cells(myRow, 5)).Value = _
Array(cboDay.Text & cboMonth.Text & cboYear.Text, cboPMType.Text, cboEquipment.Text, txtSpecs.Text, txtValue.Text & "|" & cboUnits.Text)
End Sub
 
Last edited:
Upvote 0
Untested, but maybe this would suffice because your active cell is presumably in ThisWorkbook already, on the sheet you plan to edit:


Code:
Private Sub CommandButton1_Click()
Dim myRow as Long
myRow = activecell.Row
cells(myRow, 1).Value = cboDay.Text & cboMonth.Text & cboYear.Text
cells(myRow, 2).Value = cboPMType.Text
cells(myRow, 3).Value = cboEquipment.Text
cells(myRow, 4).Value = txtSpecs.Text
cells(myRow, 5).Value = txtValue.Text & "|" & cboUnits.Text
End Sub

You might also be able to get away with this:

Code:
Private Sub CommandButton1_Click()
Dim myRow As Long
myRow = ActiveCell.Row
Range(Cells(myRow, 1), Cells(myRow, 5)).Value = _
Array(cboDay.Text & cboMonth.Text & cboYear.Text, cboPMType.Text, cboEquipment.Text, txtSpecs.Text, txtValue.Text & "|" & cboUnits.Text)
End Sub
Hi Tom, it works perfectly, cheers!
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

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