steve_bris
Registered User.
- Local time
- Today, 17:24
- Joined
- Mar 22, 2005
- Messages
- 30
Hi.
I have written a lot of pages of code and I have hardcodded all the variable names in.....now I have to change it to use outputs from the database which I have printed into a column in excel.
I think this can be done using arrays but I don't know much about them
Say the output that I have got from my database in column J is Fred....john....ben... in rows 1 and 2 and 3.
Now I have to search throught Column A and when I find the words Fred, john or ben( the ones in column J) i have to impliment some code.
I previuously hardcoded the names in it like this
introw = 0
Do
intRow = intRow + 1
Range("A" & intRow).Select
If Selection = "Fred" Then
' do stuff
Elseif Selection = "john" Then
' do stuff
Elseif Selection = "ben" Then
' do stuff
Endif
Loop until intRow = 20
How could I use arrays or some other type of code to write the loop to search if the selection is in column J.
for example i would end up with a lot more concise code like this
introw = 0
Do
intRow = intRow + 1
Range("A" & intRow).Select
If Selection = "value from array" Then
' do stuff
Endif
Loop until intRow = 20
I hope I have made what I am asking clear....I doubt it.....hehe
Any help would be greatly appreciated.
I have written a lot of pages of code and I have hardcodded all the variable names in.....now I have to change it to use outputs from the database which I have printed into a column in excel.
I think this can be done using arrays but I don't know much about them
Say the output that I have got from my database in column J is Fred....john....ben... in rows 1 and 2 and 3.
Now I have to search throught Column A and when I find the words Fred, john or ben( the ones in column J) i have to impliment some code.
I previuously hardcoded the names in it like this
introw = 0
Do
intRow = intRow + 1
Range("A" & intRow).Select
If Selection = "Fred" Then
' do stuff
Elseif Selection = "john" Then
' do stuff
Elseif Selection = "ben" Then
' do stuff
Endif
Loop until intRow = 20
How could I use arrays or some other type of code to write the loop to search if the selection is in column J.
for example i would end up with a lot more concise code like this
introw = 0
Do
intRow = intRow + 1
Range("A" & intRow).Select
If Selection = "value from array" Then
' do stuff
Endif
Loop until intRow = 20
I hope I have made what I am asking clear....I doubt it.....hehe

Any help would be greatly appreciated.