ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vlookup with varing Column length (https://www.excelbanter.com/excel-programming/401614-vlookup-varing-column-length.html)

Matadi Tappe

Vlookup with varing Column length
 
I have this code:
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC37,'PRICING TEMPLATE II .xls'!Cat_Code,2,0)"
Used Macro recorder and it works to an extent. I have to manually copy and
paste to the last text entry in cloumn AD. I can not modify code to go as
far as the last occupied cell in cloumn AD and stop. Any sugestion as to the
routine to use for this. The Answer is returned to Cell A2 on down.

Thanks
--
Tappita

joel

Vlookup with varing Column length
 
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC37,'PRICING TEMPLATE II .xls'!Cat_Code,2,0)"
LastRow = Cells(Rows.Count, 37).End(xlUp).Row

ActiveCell.Copy _
Destination:=Range(ActiveCell, Cells(LastRow, ActiveCell.Column))

"Matadi Tappe" wrote:

I have this code:
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC37,'PRICING TEMPLATE II .xls'!Cat_Code,2,0)"
Used Macro recorder and it works to an extent. I have to manually copy and
paste to the last text entry in cloumn AD. I can not modify code to go as
far as the last occupied cell in cloumn AD and stop. Any sugestion as to the
routine to use for this. The Answer is returned to Cell A2 on down.

Thanks
--
Tappita


Matadi Tappe

Vlookup with varing Column length
 
You are an expert. It works. Thanks Joel!
--
Tappita


"Joel" wrote:

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC37,'PRICING TEMPLATE II .xls'!Cat_Code,2,0)"
LastRow = Cells(Rows.Count, 37).End(xlUp).Row

ActiveCell.Copy _
Destination:=Range(ActiveCell, Cells(LastRow, ActiveCell.Column))

"Matadi Tappe" wrote:

I have this code:
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC37,'PRICING TEMPLATE II .xls'!Cat_Code,2,0)"
Used Macro recorder and it works to an extent. I have to manually copy and
paste to the last text entry in cloumn AD. I can not modify code to go as
far as the last occupied cell in cloumn AD and stop. Any sugestion as to the
routine to use for this. The Answer is returned to Cell A2 on down.

Thanks
--
Tappita



All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com