View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_6_] Otto Moehrbach[_6_] is offline
external usenet poster
 
Posts: 201
Default how do i set an entire row or column to a range?

Very good to know that Tom. I would have lost some more hair if I tried to
loop through the cells. Otto
"Tom Ogilvy" wrote in message
...
Set rngWs = Columns(colNum).Cells

set rngWs = Rows(rowNum).Cells

if you don't use the cells, you will get a range object of size 1 (the
entire column or entire row). Same with the other suggested approached

Set rngWs = cells(1,colNum).EntireColumn
? rngWs.count
1

so if you were going to loop through the cells of the column, you

wouldn't.
If you were going to insert a column or set the column width, then you

could
proceed without using the cells qualifier.

--
Regards,
Tom Ogilvy


strataguru wrote in message
...
what if i only know of the column number (or row number) based on an int
value in a field called colNum?

for example - if in my code the logic determines that the range needs
to be 3 (meaning colNum = 3)

i'm getting an error "Method 'Range' of object '_Global' failed." with
the statement:

Set rngWs = Range(colNum).EntireColumn

Thanks!


---
Message posted from http://www.ExcelForum.com/