Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default vlookup working in one instance, but not another

This code works until I get to the last line and then it fails with
this error message "AutoFill method of Range class Failed", does
anyone have a clue why?

Dim lastRow9 As Long
lastRow9 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
Range("a2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
3,FALSE)),"""",VLOOKUP(RC[1],tbl,3,FALSE))"
Range("A2").AutoFill Destination:=Range("A2:A" & lastRow9)


' Insert Column for Type
Sheets("Working Sheet").Select
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = "General"


'Populate Column D with Type
Dim lastRow8 As Long
lastRow8 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
Range("C2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
4,FALSE)),"""",VLOOKUP(RC[1],tbl,4,FALSE))"
Range("C2").AutoFill Destination:=Range("C1:C" & lastRow8) <-THIS
ROW FAILS IN MACRO
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default vlookup working in one instance, but not another

Your trying to autofill C2 into a range of C1 - CLastrow8 and you cant
do that. Pick a range to autofill that does overwrite your source
range.


Mike


On Jan 22, 3:04*pm, S Himmelrich wrote:
This code works until I get to the last line and then it fails with
this error message "AutoFill method of Range class Failed", does
anyone have a clue why?

Dim lastRow9 As Long
* * lastRow9 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
* * Range("a2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
3,FALSE)),"""",VLOOKUP(RC[1],tbl,3,FALSE))"
* * Range("A2").AutoFill Destination:=Range("A2:A" & lastRow9)

' Insert Column for Type
* * Sheets("Working Sheet").Select
* * Columns("C:C").Select
* * Selection.Insert Shift:=xlToRight
* * Selection.NumberFormat = "General"

'Populate Column D with Type
* * Dim lastRow8 As Long
* * lastRow8 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
* * Range("C2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
4,FALSE)),"""",VLOOKUP(RC[1],tbl,4,FALSE))"
* * Range("C2").AutoFill Destination:=Range("C1:C" & lastRow8) <-THIS
ROW FAILS IN MACRO


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default vlookup working in one instance, but not another

Sorry, Clarification, pick an autofill range that doesnt have your
source data in the middle of the range being autofilled. Check out the
difference between your 2 autofill statements

Mike

On Jan 22, 3:04*pm, S Himmelrich wrote:
This code works until I get to the last line and then it fails with
this error message "AutoFill method of Range class Failed", does
anyone have a clue why?

Dim lastRow9 As Long
* * lastRow9 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
* * Range("a2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
3,FALSE)),"""",VLOOKUP(RC[1],tbl,3,FALSE))"
* * Range("A2").AutoFill Destination:=Range("A2:A" & lastRow9)

' Insert Column for Type
* * Sheets("Working Sheet").Select
* * Columns("C:C").Select
* * Selection.Insert Shift:=xlToRight
* * Selection.NumberFormat = "General"

'Populate Column D with Type
* * Dim lastRow8 As Long
* * lastRow8 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
* * Range("C2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
4,FALSE)),"""",VLOOKUP(RC[1],tbl,4,FALSE))"
* * Range("C2").AutoFill Destination:=Range("C1:C" & lastRow8) <-THIS
ROW FAILS IN MACRO


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default vlookup working in one instance, but not another

I have the same problem with him. your answer is not clear for me. Could you
please aswer it in more details?

--
Thanks


"Mike H" wrote:

Sorry, Clarification, pick an autofill range that doesnt have your
source data in the middle of the range being autofilled. Check out the
difference between your 2 autofill statements

Mike

On Jan 22, 3:04 pm, S Himmelrich wrote:
This code works until I get to the last line and then it fails with
this error message "AutoFill method of Range class Failed", does
anyone have a clue why?

Dim lastRow9 As Long
lastRow9 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
Range("a2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
3,FALSE)),"""",VLOOKUP(RC[1],tbl,3,FALSE))"
Range("A2").AutoFill Destination:=Range("A2:A" & lastRow9)

' Insert Column for Type
Sheets("Working Sheet").Select
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = "General"

'Populate Column D with Type
Dim lastRow8 As Long
lastRow8 = Worksheets("Working Sheet").Cells(Rows.Count,
"B").End(xlUp).Row
Range("C2").Formula = "=IF(ISNA(VLOOKUP(RC[1],tbl,
4,FALSE)),"""",VLOOKUP(RC[1],tbl,4,FALSE))"
Range("C2").AutoFill Destination:=Range("C1:C" & lastRow8) <-THIS
ROW FAILS IN MACRO



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
Vlookup, Index, Match every instance. M.A.Tyler Excel Discussion (Misc queries) 6 May 29th 08 09:12 PM
VLOOKUP more than one instance tojo107 Excel Discussion (Misc queries) 1 May 1st 07 11:03 PM
How do I get one instance of Excel to communicate with another instance? [email protected] Excel Programming 3 November 21st 06 10:31 PM
Vlookup adding more than one instance ExcelUser777 Excel Discussion (Misc queries) 9 March 14th 06 06:57 PM
Vlookup to find Second INstance [email protected] Excel Worksheet Functions 1 September 16th 05 03:33 AM


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