Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Using a variable to set a Range

How do you use a variable to determine a range when changing properties in VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font, font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same for
both of those but the column of the cell is different than the column values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for an
inividual cell not a range.

Please Help,

Thanks,

Scott
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using a variable to set a Range

Cells(row_num, col_num)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sip8316" wrote in message
...
How do you use a variable to determine a range when changing properties in

VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way

in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font,

font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same

for
both of those but the column of the cell is different than the column

values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for

an
inividual cell not a range.

Please Help,

Thanks,

Scott



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Using a variable to set a Range

yeah I know how to do that, but Cells(row_num, col_num).whatever will only
edit one cell, I want to edit a range, all the cells in this range are in the
same row but take up 4-6 columns. How do I use a variable for a range?

"Bob Phillips" wrote:

Cells(row_num, col_num)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sip8316" wrote in message
...
How do you use a variable to determine a range when changing properties in

VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way

in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font,

font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same

for
both of those but the column of the cell is different than the column

values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for

an
inividual cell not a range.

Please Help,

Thanks,

Scott




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using a variable to set a Range

Range(Cells(start_row_num, start_col_num),Cells(end_row_num, end_col_num))

but you probably know that already too.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sip8316" wrote in message
...
yeah I know how to do that, but Cells(row_num, col_num).whatever will only
edit one cell, I want to edit a range, all the cells in this range are in

the
same row but take up 4-6 columns. How do I use a variable for a range?

"Bob Phillips" wrote:

Cells(row_num, col_num)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sip8316" wrote in message
...
How do you use a variable to determine a range when changing

properties in
VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the

way
in
which that value compares to other values on the spreadsheet,

determines
differnent cell properties for a different range of cells. (ie. font,

font
color, fill color)

As the row and columns switch for the cell Im testing they also switch

for
the Range that I want to edit the properties. The Row value is the

same
for
both of those but the column of the cell is different than the column

values
for the Range.

I have variabes declared for both the stat column and end column of

the
range but how do I set it up so that I can use variables to edit the

range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and

that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works

for
an
inividual cell not a range.

Please Help,

Thanks,

Scott






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Using a variable to set a Range

Cells(row_num, col_num).resize(newnumberofrows,newnumberofcolumns ).....

is another way.

sip8316 wrote:

yeah I know how to do that, but Cells(row_num, col_num).whatever will only
edit one cell, I want to edit a range, all the cells in this range are in the
same row but take up 4-6 columns. How do I use a variable for a range?

"Bob Phillips" wrote:

Cells(row_num, col_num)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"sip8316" wrote in message
...
How do you use a variable to determine a range when changing properties in

VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way

in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font,

font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same

for
both of those but the column of the cell is different than the column

values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for

an
inividual cell not a range.

Please Help,

Thanks,

Scott





--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Using a variable to set a Range

Hi,
setting a range of cells ...

Dim rng as Range
set rng=range("a1:c10")
rng.font.colorindex=3

HTH

"sip8316" wrote:

How do you use a variable to determine a range when changing properties in VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font, font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same for
both of those but the column of the cell is different than the column values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for an
inividual cell not a range.

Please Help,

Thanks,

Scott

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Using a variable to set a Range



"Toppers" wrote:

Hi,
setting a range of cells ...

Dim rng as Range
set rng=range("a1:c10")
rng.font.colorindex=3

HTH

"sip8316" wrote:

How do you use a variable to determine a range when changing properties in VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font, font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same for
both of those but the column of the cell is different than the column values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for an
inividual cell not a range.

Please Help,

Thanks,

Scott

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Using a variable to set a Range

"sip8316" wrote in message
...
How do you use a variable to determine a range when changing properties in
VBA?

I am setting up code for a spread sheet so that I use a loop to test a
respective cell in every row and every five or so columns. Then the way
in
which that value compares to other values on the spreadsheet, determines
differnent cell properties for a different range of cells. (ie. font,
font
color, fill color)

As the row and columns switch for the cell Im testing they also switch for
the Range that I want to edit the properties. The Row value is the same
for
both of those but the column of the cell is different than the column
values
for the Range.

I have variabes declared for both the stat column and end column of the
range but how do I set it up so that I can use variables to edit the range
properties.

I have tried Worksheets"Sheet1".Range("A1").Font.Color Index=3, and that
will do it but you can't replace the A1 with variables. I also tried
Worksheets"Sheet1".Cells(x,y).Font.Color Index=3 but that only works for
an
inividual cell not a range.


post the code m8


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
Variable Range James C. Excel Discussion (Misc queries) 3 April 2nd 09 12:41 AM
How to use a variable for a range Jeff Lowenstein Excel Worksheet Functions 1 July 26th 05 02:14 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Using Variable in RANGE Jim[_31_] Excel Programming 1 April 26th 04 01:26 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 01:55 PM.

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

About Us

"It's about Microsoft Excel"