Consulting

Results 1 to 3 of 3

Thread: Solved: Test if last column is longer than first column

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Test if last column is longer than first column

    I have code that I use to check the first column length and then check the last column length and then set the finalrow to the length of the longer of the two:

    [VBA]finalRow = Cells(Rows.Count, "A").End(xlUp).Row
    finalColumn = Cells(1, 100).End(xlToLeft).Column
    finalRowLast = Cells(Rows.Count, finalColumn).End(x1up).Row
    If finalRowLast > finalRow Then finalRow = finalRowLast[/VBA]

    However, I can't get it to work. It seems so simple but I can't figure it out.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With ActiveSheet
    finalRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    finalColumn = .Cells(1, .Columns.Count).End(xlToLeft).Column
    finalRowLast = .Cells(Rows.Count, finalColumn).End(xlUp).Row
    If finalRowLast > finalRow Then finalRow = finalRowLast
    End With
    [/vba]

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    That worked Perfectly

Posting Permissions

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