LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Using Offset on Variable Dinensioneds Object

I have passed a range of data to a variable (PMSMatchRange) that I have
dimensioned as an Object. My first For Next loop below works correctly.
However when I get into my second For Next Loop, I cannot seem to use the
Offset Method on the PMSMatchRange variable:

CorrectCompanyName = PMSMatchRange.Offset(MatchNumber - 1, 1)

Is this because it is an object? Effectively I am tyring to do a lookup off
1 column to the right of the range that I passed to this variable. Thanks

ImportSheetVbNm.Select
ImportSheetVbNm.Range("B2").Select
ImportSheetVbNm.Range(Selection, Selection.End(xlDown)).Select
NumPMSCodes = Selection.Rows.Count

vbPMSCodeList.Select
vbPMSCodeList.Range("A2").Select
vbPMSCodeList.Range(Selection, Selection.End(xlDown)).Select

Set PMSMatchRange = vbPMSCodeList.Range(Selection,
Selection.End(xlDown))

For X = 1 To NumPMSCodes
ImportSheetVbNm.Select
ImportSheetVbNm.Range("B2").Offset(X - 1, 0).Select
If IsError(Application.Match(ActiveCell.Value, PMSMatchRange,
0)) Then
MsgBox ("You have PMS Codes in your import sheet that do not
exist in your PMS Master List.")
ActiveCell.EntireRow.Select
Exit Sub
End If
Next

For X = 1 To NumPMSCodes
ImportSheetVbNm.Select
ImportSheetVbNm.Range("B2").Offset(X - 1, 0).Select
MatchNumber =
Application.WorksheetFunction.Match(ActiveCell.Val ue, PMSMatchRange, 0)
CorrectCompanyName = PMSMatchRange.Offset(MatchNumber - 1, 1)
ImportSheetVbNm.Range("C2").Offset(X - 1, 0) = CorrectCompanyName
Next
 
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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


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