View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Columns I to Q range variable definition

Hi Howard,

Am Fri, 26 Feb 2016 03:41:50 -0800 (PST) schrieb L. Howard:

What's a better way to capture the range of Columns I:Q down to last row the with an entry.

I don't know which column will have the longest list of data.

I use select here just to verify the range on the sheet, I will set the range to a range object when I find the better way.

I understand xlCellTypeLastCell is only reduced by deleting the cells. The range may be 1400 rows or only 11 as an example.


xlCellTypeLastCell is not reliable. If you have formats downwards the
existing data you will get a wrong range.
I would check the last cell of I and J and use the maximum:

LRow1 = Cells(Rows.Count, "I").End(xlUp).Row
LRow2 = Cells(Rows.Count, "J").End(xlUp).Row

Set myRng = Range("I1:J" & Application.Max(LRow1, LRow2))


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional