Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default single dimension array

I have data in a column which I have named dates. What Im doing is using an
array to get those values, then looking for a certain value, stored in 'Dat',
and getting how far down the array that value is. IM using this:
Dim Collectdat() as Variant
Collectdat = Range("Dates").Value
For A = 1 To UBound(Collectdat)
If Dat = Collectdat(A , 1) Then
Row = (A)
Exit For
End If
Next A

What I think Im doing is working with a single dimension array, as Im entering
only one column into the array, therefore I should use '= Collectdat(A), but
this does not work so Ive used the above. Could someone advise were Im going
wrong, Im now thinking that if it was a Row instead of a column this would be
correct.
Also is there a way of seeing how far down my value is without using for/next.
What I meen if the value is the 20 etc, in the array.
Regards Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default single dimension array

Robert,
Your situation sounds tailor made for the WorksheetFunction "Match".
The following works for me...

'Returns the position with the range, returns 0 if no match found.
'Note that the return value is the position in the range, which may
'not be the same as the row number.
'------------------------------
Sub FindThePosition()
Dim MyValue As String
Dim MyRange As Range
Dim Rw As Long

MyValue = "NeverUpGrade"
Set MyRange = Columns(2)
On Error Resume Next
Rw = Application.Match(MyValue, MyRange, 0)
On Error GoTo 0
MsgBox Rw
End Sub
------------------------------------

Regards,
Jim Cone
San Francisco, Ca

"RobcPettit" wrote in message
...
I have data in a column which I have named dates. What Im doing is using an
array to get those values, then looking for a certain value, stored in 'Dat',
and getting how far down the array that value is. IM using this:
Dim Collectdat() as Variant
Collectdat = Range("Dates").Value
For A = 1 To UBound(Collectdat)
If Dat = Collectdat(A , 1) Then
Row = (A)
Exit For
End If
Next A

What I think Im doing is working with a single dimension array, as Im entering
only one column into the array, therefore I should use '= Collectdat(A), but
this does not work so Ive used the above. Could someone advise were Im going
wrong, Im now thinking that if it was a Row instead of a column this would be
correct.
Also is there a way of seeing how far down my value is without using for/next.
What I meen if the value is the 20 etc, in the array.
Regards Robert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default single dimension array

Dim Collectdat() as Variant
Collectdat = Range("Dates").Value
iRow = Application.Match(Dat, Collectdat, 0)

Any array loaded directly from a range, even if a single column or
single row, is 2-dimensional.

I used iRow as the variable name to avoid using a variable name with an
assigned meaning in Excel, i.e., Row. That sometimes causes problems as
well as confusion.

Alan Beban

RobcPettit wrote:
I have data in a column which I have named dates. What Im doing is using an
array to get those values, then looking for a certain value, stored in 'Dat',
and getting how far down the array that value is. IM using this:
Dim Collectdat() as Variant
Collectdat = Range("Dates").Value
For A = 1 To UBound(Collectdat)
If Dat = Collectdat(A , 1) Then
Row = (A)
Exit For
End If
Next A

What I think Im doing is working with a single dimension array, as Im entering
only one column into the array, therefore I should use '= Collectdat(A), but
this does not work so Ive used the above. Could someone advise were Im going
wrong, Im now thinking that if it was a Row instead of a column this would be
correct.
Also is there a way of seeing how far down my value is without using for/next.
What I meen if the value is the 20 etc, in the array.
Regards Robert


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default single dimension array

Thankyou both for replys, both have been helpful. Thanks alan for
explaining about the array bieng 2 dimensional, now to use it in my
program. Thankyou
Regards Robert



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
multi dimension/axis single series bar chart larry garka Charts and Charting in Excel 0 November 1st 09 01:20 AM
Array to single column [email protected] Excel Worksheet Functions 4 February 26th 08 06:45 PM
Max of a Single-Cell Array ajd Excel Worksheet Functions 1 February 22nd 08 06:25 PM
Array input in one single cell Ischias Excel Worksheet Functions 6 December 29th 05 09:47 PM
Test for Single Character That is in an Array scallyte Excel Worksheet Functions 2 November 11th 04 04:47 PM


All times are GMT +1. The time now is 04:41 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"