Saladsamurai
09-09-2009, 01:33 PM
Okay then! :)
In the program I am working on, the user enters data into a UserForm and then the Code, does some stuff with the data and then it needs to enter the data onto the next available Row in WorkSheets(1). So I am trying to assign the indes of the Next Available Row to the variable "NextRow"
I tried using
Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
NextRow = Selection.Rows.Count + 1
AND
NextRow = ActiveSheet.UsedRange.Rows.Count + 1
The Problem with both of these is that the functions will Count a row as being used, even if there is no data in it, but if there was at some point.
That is, if I enter data in row 4 and then 'delete' it OR 'clear' it, it will still count that row.
How can I get around this?
Also, if you open a brand new worksheet and run the function
MsgBox ActiveSheet.UsedRange.Rows.Count
or
Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
NextRow = Selection.Rows.Count
MsgBox NextRow
It will always return 1. why? The first Row is empty...
Thanks.
In the program I am working on, the user enters data into a UserForm and then the Code, does some stuff with the data and then it needs to enter the data onto the next available Row in WorkSheets(1). So I am trying to assign the indes of the Next Available Row to the variable "NextRow"
I tried using
Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
NextRow = Selection.Rows.Count + 1
AND
NextRow = ActiveSheet.UsedRange.Rows.Count + 1
The Problem with both of these is that the functions will Count a row as being used, even if there is no data in it, but if there was at some point.
That is, if I enter data in row 4 and then 'delete' it OR 'clear' it, it will still count that row.
How can I get around this?
Also, if you open a brand new worksheet and run the function
MsgBox ActiveSheet.UsedRange.Rows.Count
or
Range("A1", ActiveCell.SpecialCells(xlLastCell)).Select
NextRow = Selection.Rows.Count
MsgBox NextRow
It will always return 1. why? The first Row is empty...
Thanks.