View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default Set Variable equal to........

For i = 3 to 42
For j = 1 To 20

and then refence

Cells(j,"B")

and

Cells(i,"A")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Aaron" wrote in message
...
Great! That makes sense and it works. What about the range of values?

Thank you for your help!

"Gary''s Student" wrote:

Hi Aaron:

One step at a time:

For i=1 to 10

can be replaced by variables that can be set by cell values

istart=Range("A3").Value
iend=istart+39
For i=istart to iend

So we are using the value in Cell A3 to define the start of the loop
--
Gary's Student


"Aaron" wrote:

I have a macro that is dependent upon a set of variables. Instead of
hard
coding the possibilities for the variables I want it to use values for
the 2
variables from cells in the sheet how would that work? And from a range
of
values in the spreadsheet?

I don't know if this is right or not but something like:
For i = "A3" To ("A3" + 39)
For j = "B1" To "B20" or "B1:B20" (whatever is correct code)
Actually
now that I think about it, it would need to be the "B1:B20" version if
possible because it is a set of codes not a liniear set of numbers.

Instead of:
For i = 1 To 10
For j = 1 To 10