userform help

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

0
Utf
11/19/2009 1:03:01 PM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
735 Views

Similar Articles

[PageSpeed] 9

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


"Dawna" wrote:

> 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
> 
0
Utf
11/19/2009 1:29:03 PM
Joel;563427 Wrote: 
> 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
> 
> 
> "Dawna" wrote:
> 
> > 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
> >

This may not fix it since the code writes nothing to column A, so
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 their
offsets muddled. So it's a case of writing to column A or changing the
LastRow line to:
LastRow=Range("B" & Rows.Count).End(xlUp).Row


-- 
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=155465

[url="http://www.thecodecage.com"]Microsoft Office Help[/url]

0
p45cal
11/19/2009 1:47:11 PM
Joel,
Thank you so much! works great

"Joel" wrote:

> 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
> 
> 
> "Dawna" wrote:
> 
> > 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
> > 
0
Utf
11/19/2009 2:12:01 PM
Reply:

Similar Artilces: