PDA

View Full Version : Solved: Start from the 2nd row



maninjapan
09-23-2008, 12:15 AM
I would like to leave an empty row between my entries, Ive tried adding 'Next Row + 1' instead of just 'Next Row' but that didnt work it still added to the next empty row.


Private Sub CommandButton1_Click()

' Determine the next empty row
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1

' Transfer Buy to the next empty row.
Cells(NextRow + 1, 1) = "Buy"

End Sub

Bob Phillips
09-23-2008, 01:00 AM
That worked for me, as shown in this image

maninjapan
09-23-2008, 01:04 AM
Yeah, it worked for me the first time too, but after the first time it just went back to filling every row. Could you try entering it multiple times?

Bob Phillips
09-23-2008, 01:05 AM
Just tried it a second time, and it didn't insert blank, because the existing blank wass't counted. This code circumvents that



Dim NextRow As Long

' Determine the next empty row
NextRow = Cells(Rows.Count, "A").End(xlUp).Row
' Transfer Buy to the next empty row.
Cells(NextRow + 2, 1) = "Buy"

mdmackillop
09-23-2008, 06:55 AM
or using a Range solution

Dim c As Range

Set c = Cells(Rows.Count, "A").End(xlUp).Offset(2)
c.Value = "Buy"

Slyboots
09-23-2008, 11:01 AM
Here's one more thing to think about. I've often found that when I use blank rows, I have trouble later, because I need a continuous list. To avoid that, I don't put in a blank row. Instead, I adjust the Height property of the row. When the row height increases, there's a nice space between the entries, but no blank row.

S

maninjapan
09-24-2008, 01:29 AM
XLD, thanks, works like a charm now.

MD, Thanks, Im starting to see how the same problem can be approached from completely different ways.

SlyBoots, yet another solution to the problem simple yet effective.

How do I add solved to the thread title ??

mdmackillop
09-25-2008, 08:20 AM
How do I add solved to the thread title ??
You can mark it Solved using the Thread Tools dropdown.