userform help

D

Dawna

I'm trying to insert data into the first empty cell. My code keeps
overwriting the last entry...could someone help me figure out where I've
messed up?

Thank you in advance
Dawna

Private Sub CommandButton2_Click()
Dim rRng As Range
Set rRng = Range("A" & Range("A" & Rows.Count).End(xlUp).Row)
With rRng.Offset(rRng.Count + 1, 0).Select

rRng.Offset(1, 1) = Me.TbDate
rRng.Offset(1, 3) = Me.cboname
rRng.Offset(1, 5) = Me.TbPO
rRng.Offset(1, 6) = Me.TbCustom
 
J

Joel

Private Sub CommandButton2_Click()
Dim rRng As Range

LastRow = Range("A" & Rows.Count).End(xlUp).Row
Newrow = LastRow + 1

Range("B" & Newrow) = Me.TbDate
Range("D" & Newrow) = Me.cboname
Range("F" & Newrow) = Me.TbPO
Range("G" & Newrow) = Me.TbCustom
 
P

p45cal

Joel;563427 said:
Private Sub CommandButton2_Click()
Dim rRng As Range

LastRow = Range("A" & Rows.Count).End(xlUp).Row
Newrow = LastRow + 1

Range("B" & Newrow) = Me.TbDate
Range("D" & Newrow) = Me.cboname
Range("F" & Newrow) = Me.TbPO
Range("G" & Newrow) = Me.TbCustom

This may not fix it since the code writes nothing to column A, s
unless this is done elsewhere, the line:
LastRow=Range("A" & Rows.Count).End(xlUp).Row
will return the same result each time!

I suspect the OP wants to write to column A but is getting thei
offsets muddled. So it's a case of writing to column A or changing th
LastRow line to:
LastRow=Range("B" & Rows.Count).End(xlUp).Ro
 
D

Dawna

Joel,
Thank you so much! works great

Joel said:
Private Sub CommandButton2_Click()
Dim rRng As Range

LastRow = Range("A" & Rows.Count).End(xlUp).Row
Newrow = LastRow + 1

Range("B" & Newrow) = Me.TbDate
Range("D" & Newrow) = Me.cboname
Range("F" & Newrow) = Me.TbPO
Range("G" & Newrow) = Me.TbCustom
 
Top