Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Array & variable

Hi Group,
I have gone through a worksheet that had ID numbers in it and put those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does work.
I have tried varous variations and concantinations to bring in the varible,
but have not been able to. ID1, the varaible, contains the number 4, but I
can not get that into the search.

Thanks,
--
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Array & variable

David,
Put your IDs into an array e.g ID(10) and then use:

Selection.Find(What:= ID(Q),After:.........

"David" wrote:

Hi Group,
I have gone through a worksheet that had ID numbers in it and put those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does work.
I have tried varous variations and concantinations to bring in the varible,
but have not been able to. ID1, the varaible, contains the number 4, but I
can not get that into the search.

Thanks,
--
David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Array & variable

Hi Troppers,

I tried to make it simple, thinking it would be able to accomplish the find.
I am reallt pulling in the ID, another variable i am calling W, one called L
and finally Pt. These are currently pulled in by wallking down a column and
and pulling values via an offset. So I have ID1 through ID10, W1 through W10,
L1 through L10 and Pt1 through Pt10.

I am not very good at setting up arrays and getting the values into the the
array. I believe this makes it a 10x4 array, so some thing like Dim
PlayerData(10,4), will set up the dimention, but I am not sure what to do
next, as I walk down the sheet with a simple Activecell.Offset(1,0).Select.

Thanks,

"Toppers" wrote:

David,
Put your IDs into an array e.g ID(10) and then use:

Selection.Find(What:= ID(Q),After:.........

"David" wrote:

Hi Group,
I have gone through a worksheet that had ID numbers in it and put those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does work.
I have tried varous variations and concantinations to bring in the varible,
but have not been able to. ID1, the varaible, contains the number 4, but I
can not get that into the search.

Thanks,
--
David

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Array & variable

David,
Assuming your array is PlayerDaya(10,4), you could populate it
as follows:


Dim PlayerData(10,4) as Variant (or Integer/Long if all values are numeric)


..........
PlayerData(n,1)="ID data" e.g. ActiveCell.value for ID data
PlayerData(n,2)="W data"
PlayerData(n,3)="L Data"
PlayerData(n,4)="Pt Data"
n=n+1

where n has values in range 1 to 10.

So ID1 is in Player(1,1), W1 is in PlayerData(1,2) .... ID10 is in
PlayerData(10,1).

You know the value of n as you effectively use it to assigning ID1, W1 etc .
Set n=0 initially and increment by 1 when you have assigned the last value
for that index.

You can replace ID(Q) in the FIND statement by PlayerData(Q,i) where i has a
value of 1 to 4 corresponding to ID,W,L and Pt.

HTH

"David" wrote:

Hi Troppers,

I tried to make it simple, thinking it would be able to accomplish the find.
I am reallt pulling in the ID, another variable i am calling W, one called L
and finally Pt. These are currently pulled in by wallking down a column and
and pulling values via an offset. So I have ID1 through ID10, W1 through W10,
L1 through L10 and Pt1 through Pt10.

I am not very good at setting up arrays and getting the values into the the
array. I believe this makes it a 10x4 array, so some thing like Dim
PlayerData(10,4), will set up the dimention, but I am not sure what to do
next, as I walk down the sheet with a simple Activecell.Offset(1,0).Select.

Thanks,

"Toppers" wrote:

David,
Put your IDs into an array e.g ID(10) and then use:

Selection.Find(What:= ID(Q),After:.........

"David" wrote:

Hi Group,
I have gone through a worksheet that had ID numbers in it and put those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does work.
I have tried varous variations and concantinations to bring in the varible,
but have not been able to. ID1, the varaible, contains the number 4, but I
can not get that into the search.

Thanks,
--
David

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Array & variable

Assuming the data is in a worksheet, with columns for ID, W, L and Pt.

Why don't you name the Id Range, ay rngID, and then use something like

For Q = 1 To 10
With Range("rngID")
myVal = .Offset(0Q,0) & .Offset(Q,1) & .Offset(Q,2) &
..Offset(Q,3)
End With
Selection.Find(What:=("ID"& Q), After:.........
Next



--

HTH

RP
(remove nothere from the email address if mailing direct)


"David" wrote in message
...
Hi Troppers,

I tried to make it simple, thinking it would be able to accomplish the

find.
I am reallt pulling in the ID, another variable i am calling W, one called

L
and finally Pt. These are currently pulled in by wallking down a column

and
and pulling values via an offset. So I have ID1 through ID10, W1 through

W10,
L1 through L10 and Pt1 through Pt10.

I am not very good at setting up arrays and getting the values into the

the
array. I believe this makes it a 10x4 array, so some thing like Dim
PlayerData(10,4), will set up the dimention, but I am not sure what to do
next, as I walk down the sheet with a simple

Activecell.Offset(1,0).Select.

Thanks,

"Toppers" wrote:

David,
Put your IDs into an array e.g ID(10) and then use:

Selection.Find(What:= ID(Q),After:.........

"David" wrote:

Hi Group,
I have gone through a worksheet that had ID numbers in it and put

those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another

worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does

work.
I have tried varous variations and concantinations to bring in the

varible,
but have not been able to. ID1, the varaible, contains the number 4,

but I
can not get that into the search.

Thanks,
--
David





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Array & variable

Thank you Toppers, arrays always get me and I had made this vastly more
complicated than I needed to. I thought I needed set value and stuff like
that, but what you laid out worked great. Thanks again.

Sincerely,

"Toppers" wrote:

David,
Assuming your array is PlayerDaya(10,4), you could populate it
as follows:


Dim PlayerData(10,4) as Variant (or Integer/Long if all values are numeric)


.........
PlayerData(n,1)="ID data" e.g. ActiveCell.value for ID data
PlayerData(n,2)="W data"
PlayerData(n,3)="L Data"
PlayerData(n,4)="Pt Data"
n=n+1

where n has values in range 1 to 10.

So ID1 is in Player(1,1), W1 is in PlayerData(1,2) .... ID10 is in
PlayerData(10,1).

You know the value of n as you effectively use it to assigning ID1, W1 etc .
Set n=0 initially and increment by 1 when you have assigned the last value
for that index.

You can replace ID(Q) in the FIND statement by PlayerData(Q,i) where i has a
value of 1 to 4 corresponding to ID,W,L and Pt.

HTH

"David" wrote:

Hi Troppers,

I tried to make it simple, thinking it would be able to accomplish the find.
I am reallt pulling in the ID, another variable i am calling W, one called L
and finally Pt. These are currently pulled in by wallking down a column and
and pulling values via an offset. So I have ID1 through ID10, W1 through W10,
L1 through L10 and Pt1 through Pt10.

I am not very good at setting up arrays and getting the values into the the
array. I believe this makes it a 10x4 array, so some thing like Dim
PlayerData(10,4), will set up the dimention, but I am not sure what to do
next, as I walk down the sheet with a simple Activecell.Offset(1,0).Select.

Thanks,

"Toppers" wrote:

David,
Put your IDs into an array e.g ID(10) and then use:

Selection.Find(What:= ID(Q),After:.........

"David" wrote:

Hi Group,
I have gone through a worksheet that had ID numbers in it and put those IDs
in a variable ID1, ID2, ID3...ID10. I am then going over to another worksheet
and doing a Find with in a For...Next construct

For Q = 1 To 10
Selection.Find(What:=("ID"& Q), After:.........
Next

Above does not work, although a hard code instead of =("ID"& Q), does work.
I have tried varous variations and concantinations to bring in the varible,
but have not been able to. ID1, the varaible, contains the number 4, but I
can not get that into the search.

Thanks,
--
David

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using COUNTA for a variable array Schannah Excel Worksheet Functions 5 July 22nd 08 05:02 PM
use a variable array in a formula JPderose Excel Discussion (Misc queries) 1 October 20th 05 06:24 AM
how can I see if an array contain a certain variable? Ronaldo[_2_] Excel Programming 3 November 17th 04 09:21 AM
about ARRAY variable Marek Excel Programming 3 September 13th 04 06:40 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"