Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default VBA Offset (trying to resize an element within nested array)

I'm running into a problem with application.match, and I'm thinking it may be
because my comparison array is an array equivalent to a whole column in 2007
(1MM+ rows) so I want to shorten my array to only include the area with
values.

However, my attempts to shrink the nested array have so far been unsuccessful;

Public AllRanges(1 To 10) As Variant

Sub SetRange_DemoForNewsgroupPosting
'here is code without all the extra errorchecking and processing lines
Set TempRange = Application.InputBox(Prompt:="Column?", Title:="Demo",
Type:=8)
Set PassRange = TempRange.Columns(1).EntireColumn
AllRanges(2) = PassRange.Value
End Sub

Sub ShrinkMyArray
Arr2Count = 528
Set AllRanges(2) = AllRanges(2)(1, 1).Offset(0, 0, Arr2Count, 1)
End Sub

For what it's worth, the reason I'm doing all this is because this next line
of code works on workbookA on Excel2003, but when run on workbookB on
Excel2007, it gives a runtime error 13, type mismatch:

RowMatch = Application.Match(AllRanges(1)(i, 1), AllRanges(2), False)
'AllRanges(1)(i, 1) confirmed as an expected string, so the problem has to
be with AllRanges(2). Using debug.print I confirmed that Allranges(2) is
populated with the expected data... so my best guess is that the array size
is just too large for application.match

Thank you!
Keith


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA Offset (trying to resize an element within nested array)

I would use the following:

from:
AllRanges(1)(i, 1)
to:
AllRanges(1).offset(i, 1)

AllRange will automtically return the 1st cell in the range.

I'm not sure why you are using MATCH when you can use find instead.
from
RowMatch = Application.Match(AllRanges(1)(i, 1), AllRanges(2), False)

to set c = Range(AllRanges(2)).find(what:=AllRanges(1).offset (i, 1), _
lookin:=xlvalues,lookat:=xlwhole)
"ker_01" wrote:

I'm running into a problem with application.match, and I'm thinking it may be
because my comparison array is an array equivalent to a whole column in 2007
(1MM+ rows) so I want to shorten my array to only include the area with
values.

However, my attempts to shrink the nested array have so far been unsuccessful;

Public AllRanges(1 To 10) As Variant

Sub SetRange_DemoForNewsgroupPosting
'here is code without all the extra errorchecking and processing lines
Set TempRange = Application.InputBox(Prompt:="Column?", Title:="Demo",
Type:=8)
Set PassRange = TempRange.Columns(1).EntireColumn
AllRanges(2) = PassRange.Value
End Sub

Sub ShrinkMyArray
Arr2Count = 528
Set AllRanges(2) = AllRanges(2)(1, 1).Offset(0, 0, Arr2Count, 1)
End Sub

For what it's worth, the reason I'm doing all this is because this next line
of code works on workbookA on Excel2003, but when run on workbookB on
Excel2007, it gives a runtime error 13, type mismatch:

RowMatch = Application.Match(AllRanges(1)(i, 1), AllRanges(2), False)
'AllRanges(1)(i, 1) confirmed as an expected string, so the problem has to
be with AllRanges(2). Using debug.print I confirmed that Allranges(2) is
populated with the expected data... so my best guess is that the array size
is just too large for application.match

Thank you!
Keith


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
Rules for element-by-element product in array multiplication Paul Excel Programming 2 March 22nd 08 11:42 PM
Resize offset ward376 Excel Programming 5 April 4th 07 02:14 PM
using .resize or an offset cereldine[_12_] Excel Programming 2 April 10th 06 05:51 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM


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