Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array rerun 1

Status
Not open for further replies.

Luis939

MIS
Feb 28, 2003
453
US
is there anyway to run an array once, and store a variable to each index, for example lets say i have

for i = 1 to thisworkbook.sheets.count
variable = value
next i

and then whenever i run another array with the same increment for i = 1 to thisworkbook.sheets.count
how do i have the program remember which value was stored for each index (worksheet)
 
well not not exactly, lets say each worksheet has a different value in say, cell A1.
now lets say i want to run a forloop again on every worksheet, knowing that value and doing something with it. I basically dont want again to record the value in the cell, i want to already have it in a variable to use again in the same 2nd for-loop,
hope that clarifies things, thanks!!
 
and that would work for ranges as well??
so lets say in each worksheet i locate a range such as
thisworkbook.sheets(i).range("A:A").find(what:="string")

how would i store that string to use again when i revisit the worksheet, thanks!!
 
well i should have been more specific, lets say i want to look for a string in the form "*area????.xls".
Basically some worksheets have that string, some dont. I run one for loop to collect those strings and store them in varialbes or array indexes or whatever is best. For those that do have that string, i run a forloop again and do work with only those worksheets that have that string by using those stored variables and performing some instructions.
 
You're not collecting the strings. You already know what they are, don't you? Tiy're collecting the Sheets on which the strings reside in order to streamline future processing.

Or am I still missing sumthin?

Skip,
Skip@TheOfficeExperts.com
 
i guess all it is me running that for loop once to do one set of instructions involving that string, basically that string is the name of another filename, then after all that is done, i want to go back and revisit each sheet, and take that string in those worksheets and peform another seperate set of instructions, so i dont want to have to go and search for it again when i run the 2nd forloop, i want my program to remember what string is associated with each worksheet (yea i know it seems redundant to do that, but the way i have to run this program is complicated, i just cant run both sets of instructions one after the other, they must be seperate.
 
I dont know how to do that, is that what you did before?
 
Skip, completely unrelated to the topic, but just wanted to say thanks and have a star b/c you've inadvertently taught me a new way to reference ranges (aryValue(i) = Sheets(i).[A1]).
 
krinid,

Thanx for the STAR. Believe me when I say that I learn from these Forums too. Just yesterday, a member posted a solution for a chart that I never realized existed using a Pivot Chart. And there must be millions of tips and tricks that I would like to know that other members have tucked away. :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top