brackington
New Member
- Joined
- Jul 16, 2015
- Messages
- 2
Hello,
I am brand new to VBA and this is my first post here so please bear with me. I have been researching how to use a vlookup in VBA and have been unable to come up with a solution so I thought I would ask here. I need the formula to be inserted with reference to the active cell because the cell will change dependent on how the workbook is filled out. From what I have read I should be able to do this with this code:
Range(ActiveCell.Offset(1, 2), ActiveCell.Offset(1, 2).End(xlDown)).Offset(0, 2).Formula = "= vlookup("& ActiveCell.Offset(1, 3) & ",Products!$I$5:$I$40,1,0)"
I have been able to validate that the values before the = sign work, but the lookup gives me a Run-time error '1004': Application-defined or object-defined error everytime. What am I missing? Your help with this would be greatly appreciated! Thanks so much!
I am brand new to VBA and this is my first post here so please bear with me. I have been researching how to use a vlookup in VBA and have been unable to come up with a solution so I thought I would ask here. I need the formula to be inserted with reference to the active cell because the cell will change dependent on how the workbook is filled out. From what I have read I should be able to do this with this code:
Range(ActiveCell.Offset(1, 2), ActiveCell.Offset(1, 2).End(xlDown)).Offset(0, 2).Formula = "= vlookup("& ActiveCell.Offset(1, 3) & ",Products!$I$5:$I$40,1,0)"
I have been able to validate that the values before the = sign work, but the lookup gives me a Run-time error '1004': Application-defined or object-defined error everytime. What am I missing? Your help with this would be greatly appreciated! Thanks so much!