Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Array values with UBound

Cells(x, 1) will error when x = 0 since Cells() is 1-based.

If I understand what you're doing, you could perhaps use:

Public Sub DIFFREC2()
Dim rDest As Range
Dim rCell As Range

Set rDest = Workbooks("TEST.xls").Sheets("CBOIPRIN").Cells(1, 1)
With Workbooks("factor.xls").Sheets(1)
For Each rCell In .Range(.Range("F1"), _
.Range("F1").End(xlDown))
With rCell
If .Text = "PAYD" Then
rDest.Resize(1, 4).Value = _
.Offset(0, -5).Resize(1, 4).Value
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End With
End Sub

In article .com,
wrote:

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

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
Ubound(x) gives rows in a range-array - but what about columns ? excelent Excel Programming 6 September 2nd 06 11:50 PM
Array Ubound gti_jobert[_71_] Excel Programming 6 March 27th 06 10:34 PM
UBound of multi-dimensional array? Jake Marx[_3_] Excel Programming 0 August 16th 05 06:34 PM
Handling ubound on an uninitialised array Mike NG Excel Programming 14 January 24th 05 09:05 AM


All times are GMT +1. The time now is 02:54 PM.

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"