PDA

View Full Version : Solved: Test if last column is longer than first column



Djblois
02-13-2007, 09:55 AM
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:

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

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

Bob Phillips
02-13-2007, 10:03 AM
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

Djblois
02-13-2007, 12:00 PM
That worked Perfectly