How to select the full last column of the last row in VBA?

Bassie

Board Regular
Joined
Jan 13, 2022
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
Hey,

So I know how to select last rows and last columns seperatly but I cant figure out for the life of me how to combine the two. I am trying to first find the last column and then use the & Rows.Count).End(xlUP)) to find the last row aswell and exlude the header aswell if possible.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
VBA Code:
lr = Cells(Rows.Count, Cells(7, Columns.Count).End(xlToLeft).Column).End(xlUp).Row
 
Upvote 0
VBA Code:
lr = Cells(Rows.Count, Cells(7, Columns.Count).End(xlToLeft).Column).End(xlUp).Row
Thank you! I am a bit new to VBA and it seems that it works but how do I select these cells now?
 
Upvote 0
VBA Code:
lc = Cells(7, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, Cells(7, Columns.Count).End(xlToLeft).Column).End(xlUp).Row

Cells(lr, lc).Select
 
Upvote 0
Solution

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

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