stillwillyboy
Technical User
I have the following table created using the Subtotal function:
Cust# Invoice# Amount
12 900 1000
12 1000
36 912 200
36 913 300
36 500
417 925 100
417 100
I am wanting to pull the customer name from the CustNumb worksheet that is in the same workbook as the above.
My new table would look like:
Cust# Invoice# Amount
12 900 1000
12 Eagle 1000
36 912 200
36 913 300
36 Pete’s 500
417 925 100
417 Freddy 100
The table where I am pulling the info from (custnumb) has the customer number in column A and the customer name in column B.
Below is my code. I keep getting the message: “Application-defined or Object-defined error” when running the procedure.
Sub VLookUpCopied()
Application.ScreenUpdating = False
Dim LastRow As Range
Set LastRow = Range("A65536").End(xlUp)
With ActiveCell 'Range("B1") 'B2 is Name
.Offset(0, 1).Select
‘the line below is causing the error message
.Value = "=VLOOKUP(A1, custnumb!$A$1:$c$" & LastRow & ", 2, FALSE)"
.AutoFill Destination:=Range(Cells(.Row, .Column), Cells(Cells(2, 1).End(xlDown).Row, .Column)), Type:=xlFillDefault
.Offset(0, -1).Select ‘move activecell back to column A to select next customer number and in turn _
the next customer name
End With
Application.ScreenUpdating = True
End Sub
Thoughts?
TIA
Cust# Invoice# Amount
12 900 1000
12 1000
36 912 200
36 913 300
36 500
417 925 100
417 100
I am wanting to pull the customer name from the CustNumb worksheet that is in the same workbook as the above.
My new table would look like:
Cust# Invoice# Amount
12 900 1000
12 Eagle 1000
36 912 200
36 913 300
36 Pete’s 500
417 925 100
417 Freddy 100
The table where I am pulling the info from (custnumb) has the customer number in column A and the customer name in column B.
Below is my code. I keep getting the message: “Application-defined or Object-defined error” when running the procedure.
Sub VLookUpCopied()
Application.ScreenUpdating = False
Dim LastRow As Range
Set LastRow = Range("A65536").End(xlUp)
With ActiveCell 'Range("B1") 'B2 is Name
.Offset(0, 1).Select
‘the line below is causing the error message
.Value = "=VLOOKUP(A1, custnumb!$A$1:$c$" & LastRow & ", 2, FALSE)"
.AutoFill Destination:=Range(Cells(.Row, .Column), Cells(Cells(2, 1).End(xlDown).Row, .Column)), Type:=xlFillDefault
.Offset(0, -1).Select ‘move activecell back to column A to select next customer number and in turn _
the next customer name
End With
Application.ScreenUpdating = True
End Sub
Thoughts?
TIA