Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How to have the number of last free cell in range A2:IV2...
    In this my case 4 (D2 is the free last cell)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can use

    LastCol = Range("IV2").End(xlToLeft).Column + 1

    or if you want to be certain it'll work in Excel 2007 and later too:

    LastCol = Cells(2, Columns.Count).End(xlToLeft).Column + 1

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='761383' date='25-Feb-09 13:09']You can use

    LastCol = Range("IV2").End(xlToLeft).Column + 1

    or if you want to be certain it'll work in Excel 2007 and later too:

    LastCol = Cells(2, Columns.Count).End(xlToLeft).Column + 1[/quote]
    good!

  4. #4
    3 Star Lounger
    Join Date
    Jan 2002
    Location
    The Hague, Netherlands
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='sal21' post='761380' date='25-Feb-2009 12:58']How to have the number of last free cell in range A2:IV2...
    In this my case 4 (D2 is the free last cell)[/quote]

    Doing it by means of a formula:

    Control+shift+enter, not just enter...

    =MATCH(2,1/(1-ISBLANK(A2:IV2)))+1

    If A2:IV2 is empty (unused), the result will be #N/A.
    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •