Hi everyone, I just started using macros in Excel few days ago and I am a bit stuck in my code.
I receive a weekly report (Excel file) from a forwarder and I use it to complete another Excel file ("sea log"). I used to do a serie of VLOOKUP but it really takes long (lots of columns to fill) and started thinking about a macro that would do the job in one click (or two).
The 'report' file only shows the latest shipments whereas the 'sea log' file is used for analysis and keeps track of shipment from 2012 until now.
I don't want the macro to run on all rows as it replace my 2012-2013 data with #N/A.
This is what my code looks like so far :
Rows 6992 to 7003 are the new shipments that I need to update this week, but next week it will be different. I don't feel like changing the figures manually every week...![]()
Sub SeaLogUpdate() With Sheets("CTN Data") .Range("B6992:B7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:D"), 4, False) .Range("D6992:D7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:G"), 7, False) .Range("E6992:E7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:N"), 14, False) .Range("F6992:F7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:R"), 18, False) .Range("I6992:I7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:V"), 22, False) .Range("J6992:J7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:W"), 23, False) .Range("G6992:G7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:L"), 12, False) .Range("M6992:M7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:AH"), 34, False) .Range("N6992:N7003").Value = WorksheetFunction.VLookup(.Range("A6992:A7003").Value, Sheets("REPORT").Range("A:Y"), 25, False) End With End Sub
Is there a way to have an input box that ask for 'start row' and 'end row' values before running the VLOOKUP macro ?
Or maybe you know another way to do it ?
Thanks !
Bookmarks