Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do i set an entire row or column to a range?

hi,

how do i set an entire row or an entire column to a range?

thanks

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how do i set an entire row or column to a range?

You're gonna laugh:

set rng = Range("A1").EntireColumn

or

set rng = Range("A1").EntireRow

And they call it BASIC??

-Brad
-----Original Message-----
hi,

how do i set an entire row or an entire column to a range?

thanks!


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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default how do i set an entire row or column to a range?

Hi,

Is this what you are looking for?

Sub SetRanges()
Dim rng As Range

MsgBox "First the column... "
Set rng = Range("G:G")
rng.Select

MsgBox "and now the row... "
Set rng = Range("20:20")
rng.Select

MsgBox "and now back to home. "
Range("A1").Select

End Sub

I hope that helps.

Rick

-----Original Message-----
hi,

how do i set an entire row or an entire column to a range?

thanks!


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

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do i set an entire row or column to a range?

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/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default how do i set an entire row or column to a range?

Use:
Set rngWs = Cells(1,ColNum).EntireColumn
HTH Otto

"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/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how do i set an entire row or column to a range?

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/



  #8   Report Post  
Posted to microsoft.public.excel.programming
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/





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Unique Values in a entire column, not just range Brian Excel Worksheet Functions 10 May 16th 09 08:48 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
If data in one column, take date, add 2 days, and turn the entire column a color... [email protected] Excel Discussion (Misc queries) 6 August 24th 06 03:58 AM
my column is sorted in two sections. How do I sort entire column? Elcar Excel Discussion (Misc queries) 0 February 13th 06 08:41 PM
my column is sorted in two sections. How do I sort entire column? Bob Umlas, Excel MVP Excel Discussion (Misc queries) 0 February 13th 06 08:41 PM


All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"