PDA

View Full Version : [SOLVED:] Last cell selected



Mark
08-06-2007, 06:22 AM
Good Morning All,

I am a rookie at VBA and excel macros and I am hopeful someone can help me with a question. I have searched the forum for an answer to my problem but have not come across it yet. That's why I am asking the question here.

I know the code to select that last cell in a range (if the cell is different every time) is: Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

What code to I add to this if I want to then go to the next row and move all the way to column A?

Basically what I am trying to do accomplish is merge data from multiple worksheets into one worksheet, pasting the new data at the end of the previous data. I hope that makes sense.

So it's like hitting ctrl-end, the enter key, and then the Home key.

Any direction is greatly appreciated.

Have a great day.

Mark

Bob Phillips
08-06-2007, 06:27 AM
With ActiveCell.SpecialCells(xlLastCell)
.Offset(1, -.Column + 1).Select
End With

Mark
08-06-2007, 06:28 AM
Or another way to say it is how to I get my cursor to the first empty cell in column A?

Bob Phillips
08-06-2007, 06:29 AM
That's different



Range("A1").End(xlDown).Offset(1,0).Select

rory
08-06-2007, 06:29 AM
If there is always data in column A for a given row, you can use:

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

or


Cells(ActiveCell.SpecialCells(xlLastCell).Row + 1, "A").Select

Regards,
Rory

Mark
08-06-2007, 06:37 AM
Thank you xld and rory for replying so quickly. I greatly appreciate your efforts.

rory - the code "Cells(ActiveCell.SpecialCells(xlLastCell).Row + 1, "A").Select" works perfectly! I believe this will do exactly what I am looking for.

Thanks again, xld and rory.

austenr
08-06-2007, 11:19 AM
If your question s has been answered successfully please mark your thread as solved. Thanks

mdmackillop
08-06-2007, 11:21 AM
Hi Mark,
Be aware of the difference in the two codes.
Xld will find the first empty cell, starting from A1
Rory will find the empty cell below the last used cell in any column.
These may be the same cell, but not always.

Mark
08-06-2007, 11:30 AM
If your question s has been answered successfully please mark your thread as solved. Thanks

Sorry austenr, I didn't realize I had to do that. I just made that correction.

austenr
08-06-2007, 11:31 AM
Thanks.