1

What would the equivalent to this be for the horizontal/colum?

v = Sheets("Sheet2").Range("A65536").End(xlUp).Row

I am guessing this but do not know how to check

v = Sheets("Sheet2").Range("zz1").End(xlRight).column

I am basically trying to figure out the how many columns there are. I tried what I guessed but it is wrong

Community
  • 1
  • 1
Alexis Moreno
  • 375
  • 1
  • 5
  • 15
  • `xlRight` should be `xlToLeft` – Scott Craner Aug 10 '16 at 17:46
  • 1
    This is probably a duplicate of one of these: http://stackoverflow.com/questions/33545516/finding-last-column-and-then-finding-the-last-row-in-that-column http://stackoverflow.com/questions/11926972/excel-vba-finding-the-last-column-with-data http://stackoverflow.com/questions/17730639/how-to-find-and-select-the-last-column-in-vba – Alexis Olson Aug 10 '16 at 17:47

1 Answers1

1

To get the index of the last column in the sheet, use Cells(1,Columns.Count).Column

To get the last used Column, it is very similar.

Cells(1,Columns.Count).End(xlToLeft).Column
PartyHatPanda
  • 712
  • 8
  • 14