View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Kilmer[_2_] Bob Kilmer[_2_] is offline
external usenet poster
 
Posts: 71
Default For and If Then loops, and remembering a value

Create a variable of the type of what you want to remember about "column
45", then assign the variable the value of (or the reference to) "column 45"
when K is 45.

I am not sure what you want to remember about "column 45" but I'll assume it
is the 45th column itself.

Dim rCol45 as Range
For K=53 to 6 Step -1
If K = 45 and "a cell is 0" Then
Set rCol45 = Columns(45)
'etc.
End If
Next K

rCol45.Cells(1).Value = "X" 'asigns "X" to first cell in Columns(45)

If this doesn't help, clarify.

Bob


"Art" wrote in message
...
Hi
I have a test: For K=53 to 6 Step -1, If the value in a cell is 0, then

add a chart. If the value in the cell is not 0, then reduce the column
number by one and test again. Repeat until true. If it is true in column
45, I would like it to remember column 45 so that I can use that column
reference later, but outside of that loop. I tried using "K", but the loop
continues to run down to 5. How do I stop the loop from continuing, or can
I? How do I remember column 45?

Thanks for the help. This is a great newsgroup.

Art