Find last cell in a sheet

Tim in Toronto

New Member
Joined
Nov 18, 2004
Messages
47
Hi All! I know this is going to have a simple solution, but I can't seem to make it work. I need my macro to find the last cell (bottom-right) in a spreadsheet, and then select all the cells from that point back to A1.

The last cell won't always be in the same location, so I need to consider that too.

Any ideas?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Something like this:
Code:
ActiveSheet.Range([A1], Cells.SpecialCells(xlCellTypeLastCell)).Select
Just note that you generally don't need to select objects to work with them.

What're you trying to do?

Smitty
 
Upvote 0
You might also try:

Code:
    ActiveSheet.UsedRange.Select

Though, as Smitty said:
pennysaver said:
Just note that you generally don't need to select objects to work with them.

So, if you wanted to bold all those cells, for example, you could do:

Code:
    ActiveSheet.UsedRange.Font.Bold = True

Hope that helps!

P.S. I have had problems with UsedRange not reporting the range I wanted exactly, so test it a couple times first to make sure it does what you want.

Hey Smitty!
 
Upvote 0
Hi Smitty,

Unfortunately that doesn't always work. I need to find the last cell that actually contains data. Sometimes Excel thinks that an empty cell lost in the sea of cells is the last one. Basically what I need to do for my print outs, is to highlight all the actual data and apply all the pretty boarders.

Me :)
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top