Question:
A command in Excel Macro makes cursor goes to next "down one" empty cell?
passerby
2008-08-30 18:30:46 UTC
Any command can make the cursor goes to an empty cell in same column please? the "Record new marco" funtion using (Selection.End(xlDown).Select) that only point to the last record and it does not go to the next one, hence every new record in will stands in the same row and replaced the old record, in fact I would like income new record to be appended after the last record ?
Three answers:
garbo7441
2008-08-30 18:42:26 UTC
If you want to select the cell just below the last cell containing data in a column, here is how to reference it:



(Assume Col A is the active column)



Range("A65536").End(xlUp).Offset(1, 0).Select



Note: Using End(xlDown) will not work if you have a blank cell in the column you are using. It will find the first blank cell in the column and stop. Use End(xlup) to always find the last cell in a column containing data.
devilishblueyes
2008-09-03 06:42:46 UTC
Garbo7441 is right to an extent, but you want to avoid specifying the last cell in Excel using a hard number such as 65,536. The reason you want to avoid using a hard number is because Excel 2007 has more rows than 65,536 and some older versions of Excel have less than 65,536. That number will work for Excel 2003 though.



Instead of doing it like this:



Range("A65536").End(xlUp).Offset(1, 0).Select



It's better to let Excel calculate what the last row is.



Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select



Rows.Count tells you how many rows are in that worksheet. The 1 after Rows.Count specifies the first column or Column A.
2008-08-30 18:47:40 UTC
"Give a man a fish ..."



For *any* Excel macro, record a macro (Macro/Record). Do the action. Stop recording. Excel has written the macro for you.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...