Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Subscript Out Of Range Error?

Hello Everyone,

Can somebody tell me why this gets a Subscript out of range error??? It
errors out at the vArray(I) at the bottom.

Sub findLastCell_Without_Scrolling()
Dim lLastrow As Long, vArray As Variant
Dim scrollCol As Integer, scrollRow As Integer
Dim I As Integer
'store the scroll settings
scrollCol = ActiveWindow.ScrollColumn
scrollRow = ActiveWindow.scrollRow
'set a range variable to the first blank
lLastrow = Range("A1").End(xlDown).Row
'apply the stored scroll settings

ActiveWindow.ScrollColumn = scrollCol
ActiveWindow.scrollRow = scrollRow
'display the cell found
'MsgBox firstBlank.Address

vArray = Range("A1:A" & lLastrow).Value

For I = 1 To lLastrow
If vArray(I) = "11/10/2004" Then MsgBox "The Date is " & I: Exit For
Next I

'write results out to a column range
Range("G5:G" & lLastrow).Value = vArray

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Subscript Out Of Range Error?


Need to dimension the array
Dim vArray(100) as Varian

--
crispb
-----------------------------------------------------------------------
crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088
View this thread: http://www.excelforum.com/showthread.php?threadid=27641

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subscript Out Of Range Error?

That won't fix the problem. the problem is that an array picked up in this
fashion is two dimensional

If vArray(I,1) = "11/10/2004" Then MsgBox "The Date is " & I: Exit For

should work.

however, you pick up from 1 to Lastrow and write out to 5 to lastrow.
Should it be 5 to lastrow + 4

--
Regards,
Tom Ogilvy

"crispbd" wrote in message
...

Need to dimension the array
Dim vArray(100) as Variant


--
crispbd
------------------------------------------------------------------------
crispbd's Profile:

http://www.excelforum.com/member.php...o&userid=10880
View this thread: http://www.excelforum.com/showthread...hreadid=276412



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Subscript Out Of Range Error?

Thanks Tom,

It worked perfectly. As far as the "5 to lastrow + 4", I am just playing
around with the arrays to be able to look up data that I put into an array.
I can use the formulas array function just fine with vlookup, but I wanted
to be able to do it with VBA. Actually, what I really want to do is load my
info into an array. Then search for a paticular date and then use the
celloffset to look up a name that is matched with that date. Once I get
that accomplished, then I will be able to setup a userform that will tell me
which bills are due and which bills have an auto debit. All kindergarten
stuff to you, but a learning experience for me. I am slowly getting there
with all your wonderful help. I have got 10 books, and bought the Visual
Basic Macros/Samples Made Easy. It helps a lot, but still can't get all the
info that I need. Thanks again for your help!! I only wish I knew half of
what you know about Excel VBA.
mv

"Tom Ogilvy" wrote in message
...
That won't fix the problem. the problem is that an array picked up in
this
fashion is two dimensional

If vArray(I,1) = "11/10/2004" Then MsgBox "The Date is " & I: Exit For

should work.

however, you pick up from 1 to Lastrow and write out to 5 to lastrow.
Should it be 5 to lastrow + 4

--
Regards,
Tom Ogilvy

"crispbd" wrote in message
...

Need to dimension the array
Dim vArray(100) as Variant


--
crispbd
------------------------------------------------------------------------
crispbd's Profile:

http://www.excelforum.com/member.php...o&userid=10880
View this thread:
http://www.excelforum.com/showthread...hreadid=276412





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
Error:Subscript out of range Jay Excel Discussion (Misc queries) 1 April 10th 08 10:25 PM
Subscript out of range error moglione1 Excel Discussion (Misc queries) 2 August 30th 05 01:21 PM
Help on subscript out of range error (VB6/VBA) farmer[_2_] Excel Programming 2 November 2nd 03 04:19 PM
Subscript out of range error Chris M.[_3_] Excel Programming 1 August 27th 03 05:03 PM
Subscript out of range error Gary[_4_] Excel Programming 1 August 13th 03 07:20 AM


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