Find Last Column

alexaronson

Active Member
Joined
Sep 30, 2005
Messages
314
Hello and thank you for taking the time to review my question.,

I am trying to calculate the numerical value of the last Column with data in a work sheet from Cell A3 so that I can do some fun stuff to the right of it. I do not need to know the column locations such as A, B, AA, but rather, I need to know how many columns from A the last column resides in.

I know how to find the last row by using the following code:
LastRow = Range("B" & Rows.Count).End(xlUp).Row

However, when I try using the same logic for finding last column, I seem to not be able to return any values.

Any suggestions or advice would be greatly appreciated.
 
Code:
lastcolumn = cells(3,columns.count).End(xltoleft).Column
should be the equivalent, based on row 3.
 
Upvote 0
alexaronson,


Rich (BB code):
Dim LastColumn As Long, strColName As String

'Working in row 3, will return the last used column number
LastColumn = Cells(3, Columns.Count).End(xlToLeft).Column

'This will return the column Letter(s)
strColName = Replace(Cells(1, LastColumn).Address(0, 0), 1, "")
 
Upvote 0

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