Hi, I currently run a report every morning that manipulates exported raw data to show the information needed. The majority of this report and the code was built by someone else a long time ago, but I have added to this to make it quicker and better...
However, I am having problems with a VLOOKUP that can cause me to waste quite a bit of my time copying and pasting from the previous Worksheet every morning! I would really appreciate some help with this:
Column A holds the identity of each row using a number (eg 1-123456789). Column K holds the 'Comments' relating to the particular data of this row. What the VLOOKUP does is it uses the row ID number 1-123456789 in my ActiveSheet, and searches to see if it is located in the PreviousSheet. If it finds it, it then copies the cell in column K of that row only from PreviousSheet and pastes it into the cell in column K on the row in ActiveSheet that has the same row ID number. (Really not sure if I've explained it clearly here, see images and code below).
I have two problems:
1. The ID 1-123456789 is hardly ever located on row 5 for example, it can change everyday. When this happens the column K value returns #N/A, meaning I have to use the ID no. to manually find locate, copy and paste from the previous worksheet.
2. Even if the VLOOKUP is successful, it doesn't paste the value of the cell, only the formula. So I have to manually copy and paste every single cell in column K to be able to add to the 'Comments'.
Code below for VLOOKUP:
I got this code from forums quite a while back.
Again, any help is much appreciated.
However, I am having problems with a VLOOKUP that can cause me to waste quite a bit of my time copying and pasting from the previous Worksheet every morning! I would really appreciate some help with this:
Column A holds the identity of each row using a number (eg 1-123456789). Column K holds the 'Comments' relating to the particular data of this row. What the VLOOKUP does is it uses the row ID number 1-123456789 in my ActiveSheet, and searches to see if it is located in the PreviousSheet. If it finds it, it then copies the cell in column K of that row only from PreviousSheet and pastes it into the cell in column K on the row in ActiveSheet that has the same row ID number. (Really not sure if I've explained it clearly here, see images and code below).
I have two problems:
1. The ID 1-123456789 is hardly ever located on row 5 for example, it can change everyday. When this happens the column K value returns #N/A, meaning I have to use the ID no. to manually find locate, copy and paste from the previous worksheet.
2. Even if the VLOOKUP is successful, it doesn't paste the value of the cell, only the formula. So I have to manually copy and paste every single cell in column K to be able to add to the 'Comments'.
Code below for VLOOKUP:
Code:
'Select Cell K3 ready for comments Macro
ActiveSheet.Cells(3, 11).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-10],'" & ActiveSheet.Previous.Name & "'!RC[-10]:R[97]C,11,FALSE)"
Range("K4").Select
I got this code from forums quite a while back.
Again, any help is much appreciated.