Finding the last used Column

Closed
Al - Oct 18, 2015 at 09:10 AM
 Rayh - Nov 3, 2015 at 12:27 PM
Hello,
Can anyone help. I want to find the last column used so that I can compare it with the first column


2 replies

vcoolio Posts 1362 Registration date Thursday July 24, 2014 Status Moderator Last seen September 29, 2022 250
Oct 20, 2015 at 05:31 AM
Hello Al,

See if this is what you are wanting:-

Sub FindLastColumn()

    Dim lCol As Long
    
        lCol = Sheet1.Cells(1, Columns.Count).End(xlToLeft).Column
        Columns(lCol).Select
        MsgBox "The last column used is...." & lCol
        
End Sub


Cheerio,
vcoolio.
0
Thanks for the reply, I should of said, I wanted to do it in WB not VBA
0
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768
Oct 22, 2015 at 11:38 AM
then use FIND
0
Al > rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022
Oct 23, 2015 at 07:05 AM
Thank you for that. Could you please give a little more info. How do I use 'FIND'?
0
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768 > Al
Nov 2, 2015 at 02:50 PM
I stand corrected. Find will not easily work for you. A VBA code is needed
0
Al > rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022
Nov 3, 2015 at 10:24 AM
Thanks anyway.
0
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768
Nov 3, 2015 at 12:01 PM
You can use CONTROL + END. It should stop at the intersection of max row used and max column used.
0