M
mareharbor
I am having trouble putting my array values into another sheet. I know
that the correct values are in there but i can't get them to output. I
have two variations. One uses UBound and the other just uses my
counter from building the array.
Public Sub DIFFREC2()
Windows("factor.xls").Activate
Dim MRange As Range
Set MRange = Range(Range("F1"), Range("F1").End(xlDown))
Dim cell As Variant
Dim rw As Integer
Dim x As Integer
Dim y As Integer
Dim arrTicker() As String
rw = 0
For Each cell In MRange
If cell.Value = "PAYD" Then
ReDim Preserve arrTicker(4, rw)
arrTicker(0, rw) = cell.Offset(0, -5).Value
arrTicker(1, rw) = cell.Offset(0, -4).Value
arrTicker(2, rw) = cell.Offset(0, -3).Value
arrTicker(3, rw) = cell.Offset(0, -2).Value
rw = rw + 1
End If
Next cell
Windows("TEST.xls").Activate
Sheets("CBOIPRIN").Select
x = 0
For y = 0 To rw - 1
' or y = 0 To UBound(arrTicker) either doesn't work
Cells(x, 1).Value = arrTicker(0, y)
Cells(x, 2).Value = arrTicker(1, y)
Cells(x, 3).Value = arrTicker(2, y)
Cells(x, 4).Value = arrTicker(3, y)
x = x + 1
Next
End Sub
that the correct values are in there but i can't get them to output. I
have two variations. One uses UBound and the other just uses my
counter from building the array.
Public Sub DIFFREC2()
Windows("factor.xls").Activate
Dim MRange As Range
Set MRange = Range(Range("F1"), Range("F1").End(xlDown))
Dim cell As Variant
Dim rw As Integer
Dim x As Integer
Dim y As Integer
Dim arrTicker() As String
rw = 0
For Each cell In MRange
If cell.Value = "PAYD" Then
ReDim Preserve arrTicker(4, rw)
arrTicker(0, rw) = cell.Offset(0, -5).Value
arrTicker(1, rw) = cell.Offset(0, -4).Value
arrTicker(2, rw) = cell.Offset(0, -3).Value
arrTicker(3, rw) = cell.Offset(0, -2).Value
rw = rw + 1
End If
Next cell
Windows("TEST.xls").Activate
Sheets("CBOIPRIN").Select
x = 0
For y = 0 To rw - 1
' or y = 0 To UBound(arrTicker) either doesn't work
Cells(x, 1).Value = arrTicker(0, y)
Cells(x, 2).Value = arrTicker(1, y)
Cells(x, 3).Value = arrTicker(2, y)
Cells(x, 4).Value = arrTicker(3, y)
x = x + 1
Next
End Sub