LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
UB UB is offline
external usenet poster
 
Posts: 120
Default Subscript out of range error


Hi
I am getting subscript out of range error in my code.

But if I change the For statement
from
For i = 1 to ubound(a)
to
For i = 1 to 8000
it works.
Ubound(a) has 8266 rows

My Code is:

Dim lastrow As Integer
Dim a As Variant
Dim i As Double
Dim k As Double

Dim ca() As Variant
'break


lastrow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

a = Worksheets("Sheet1").Range("a2", "d" & lastrow).Value
ReDim ca(1 To UBound(a, 1), 1 To 4)

k = 1
i = 1

For i = 1 To UBound(a, 1)

If a(i, 3) = "Y" Then

ca(k, 1) = a(i, 3)


k = k + 1

End If

Next i
Worksheets("Sheet4").Range("b3").Resize(UBound(a, 1), 1).Value = ca


*******
Please advise how can I correct this
 
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
Subscript out of range error? salgud Excel Programming 3 April 7th 09 08:46 PM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


All times are GMT +1. The time now is 12:15 PM.

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

About Us

"It's about Microsoft Excel"