Hello, first time user, very ignorant in Excel, thanks for your service. This is the first MACRO I have ever recorded (did not create it in VBA, just recorded my steps). I am trying to run a daily vlookup with the next sheet over but when I run the MACRO that I recorded, it runs the vlookup against the sheet I selected when I first recorded it. This would be sheet '5.11' below:
I want the vlookup to automatically run against the next sheet. So if i am running the MACRO on sheet 5.12, it should run the vlookup with sheet 5.13 and not 5.11. I have a workbook with one sheet per day, and I run the vlookup daily comparing to the data of the next sheet (next day). Thank you!
Code:
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Select
ActiveCell.FormulaR1C1 = "V-Balance"
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Select
ActiveCell.FormulaR1C1 = "diff w next"
ActiveCell.Offset(1, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7],'5.11'!R1:R1048576,7,FALSE)"
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(0, -1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
I want the vlookup to automatically run against the next sheet. So if i am running the MACRO on sheet 5.12, it should run the vlookup with sheet 5.13 and not 5.11. I have a workbook with one sheet per day, and I run the vlookup daily comparing to the data of the next sheet (next day). Thank you!