Posted to microsoft.public.excel.programming
|
|
Varying a macro based on a cell's value
Thanks Tim, will try it out. Neal
"Tim Williams" wrote:
"Neal Zimm" wrote in message
...
I'm just getting into macros and VB in excel. Don't really know VB
but am
picking it up as I go along. Am familiar with some other programming
languages.
Question 1:
Please help with a 'simple' (?) way to start a macro based on the
value in a
cell.
Example: In a macro that is looking at column G, starting from row 1
and
going down, as soon as the letter "z" is found in the first
position, I want
to execute another macro.
dim r as range
set r=thisworkbook.sheets("sheetname").range("G1")
do while r.value<""
if r.value like "z*" then
'call your code here
end if
set r=r.offset(1,0)
loop
Question 2: What is a way (or more if there is more than one way) to
get a
cell's value, into a macro to vary the performance of that macro?
Example: In a specfic cell whose reference I know, say r1c1, will
be a
number, say 40. In a macro, I want to do something 40 times.
dim z as long, x as long
z=thisworkbook.sheets("sheetname").range("A1").val ue
for x=1 to z
'do your thing
next z
Hope this helps,
Tim.
Thanks so much, Neal Z
|