Forum Discussion
Macro to vlookup from a list if specific text is met
- Aug 25, 2022
Thank you. As I mentioned, DC2_startrow and DC2_lastrow are row numbers on the source sheet.
You use them as row numbers on the destination sheet. That makes no sense.
Can you explain in words what you're trying to accomplish with this macro (which belongs in a standard module, by the way, not in a worksheet module)?
You look through cells on Destws, but the loop bounds DC2_startrow and DC2_endrow are calculated based on ws. Do the sheet match exactly?
And you specify 1 as column index in VLookup, so it should return the search value.
As usual, it is impossible to know what goes wrong without seeing the workbooks.
- hrh_dashAug 25, 2022Iron Contributor
Hi HansVogelaar , there will be 2 workbooks. Source and Dest.
Source wb will be the file containing the macro.
i tried to insert an IF ELSE function but it doesn't solve the issue. I only need to vlookup based on values that are DC2.
Attaching both files for your reference.
- HansVogelaarAug 25, 2022MVP
Thank you. As I mentioned, DC2_startrow and DC2_lastrow are row numbers on the source sheet.
You use them as row numbers on the destination sheet. That makes no sense.
Can you explain in words what you're trying to accomplish with this macro (which belongs in a standard module, by the way, not in a worksheet module)?
- hrh_dashAug 25, 2022Iron Contributor
HansVogelaar , i finally got what you meant on the DC2_startrow and DC2_lastrow.
It is not a worksheet module because vlookup will only be run when the code is executed not and not executed automatically.
Now the code runs perfectly fine.
Apologies for the trouble.