LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default New array with old array elements

Not sure but instead of -

For Each cell In Ratings
ReDim Preserve Ratings1(3, rw)
Ratings1(0, rw) = Application.VLookup(cell.Value,
Sheets("Portfolio").Range("EK4:EL1200"), 2, False)


Try
REdim Ratings1(lBound(Ratings) to Ubound(Ratings), _
lBound(Ratings, 2) to Ubound(Ratings, 2)

then as I mentioned before

For rw = lBound(Ratings, 2) to Ubound(Ratings, 2)
Ratings1(0, rw) = I don't understand the lookup part
If you need to track the original cell row ref, give Ratings an extra level
in the first dimension and store
the row number in that for later use with the Lookup

and why the rw = rw - 1
maybe Step - 1 ?
Ratings1(1, rw) = Ratings(1, rw)
Ratings1(2, rw) = Ratings(2, rw)
Next

In passing -
Dim Ratings(), rTicker(), Ratings1() As String

is same as
Dim Ratings() As Variant, rTicker() As Variant, Ratings1() As String

perhaps also
Dim rw as Long

Regards,
Peter T

Here i have slimmed down the code and gotten rid of all the file paths
and assumed that the different sheets are all in the same workbook. I
think that it is clearer. Thanks a bunch

Public Sub Updater()
Dim cell As Variant
Dim x, y As Integer
Dim Ratings(), rTicker(), Ratings1() As String
Dim AsDte As Date
Dim iLastRow, i As Long
AsDte = InputBox("What Is the As-of-day?")
'Creates the first array given that the date in that column is greater
then AsDte
i = 2
While (Sheets("All Actions").Cells(i, 9) < "")
If UCase(Trim(Sheets("All Actions").Cells(i, 9))) AsDte Then
ReDim Preserve Ratings(3, rw)
Ratings(0, rw) = Sheets("All Actions").Cells(i, 2).Value
Ratings(1, rw) = Sheets("All Actions").Cells(i,
3).Value
Ratings(2, rw) = Sheets("All Actions").Cells(i, 7).Value
rw = rw + 1
End If
i = i + 1
Wend

'this sheet has 2 columns the first with the contents of Ratings(o,
rw) and the second with another identifier
'that i want in the new array Ratings1 instead of the old identifier

Sheets("Portfolio").Activate
'I realize that there are issues with the vlookup but i really want to
know how to create the new array
'with the old data
For Each cell In Ratings
ReDim Preserve Ratings1(3, rw)
Ratings1(0, rw) = Application.VLookup(cell.Value,
Sheets("Portfolio").Range("EK4:EL1200"), 2, False)
Ratings1(1, rw) = Ratings(1, rw)
Ratings1(2, rw) = Ratings(2, rw)
rw = rw - 1
Next cell

End Sub



 
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
Use formulas for array elements hmm Excel Discussion (Misc queries) 3 December 3rd 07 01:15 PM
array elements count madeleine[_2_] Excel Programming 6 December 8th 06 03:36 AM
Reference Elements w/in an Array M Moore Excel Discussion (Misc queries) 2 October 16th 06 03:33 PM
Non-unique elements in an array Andrew Excel Discussion (Misc queries) 1 August 22nd 05 11:58 AM
Number of elements in an array Neal Zimm Excel Programming 4 August 12th 05 11:30 AM


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