Dear VBA/Macro Experts,
I have a task to fetch the data based on either first column barcode or second column SKU code. It will fetch details from Master Sheet for PRODUCT DETAILS and Selling Price and then an input box prompt will display to enter quantity, once I enter quantity it will calculate Amount by multiplying selling price and Quantity. I created a shortcut key to execute the code.
Below attached Image reference of my columns and when I click to run my code it does everything and starts from a fresh row again. But my requirement is when I click shortcut key it should jump to the column where formula should apply, in this case, column C and D. I'm not able to get the right way where when I enter shortcut key it should starts from column C and D and the cursor should end at in the next row first column. Because right now I'm manually moving my cursor after entering my barcode or SKU code and then moving my cursor to C to apply shortcut key. But it should be dynamically applied to all rows of the same column.
my code:
Sub EasyTool()
'
' EasyTool for Platina Sales
'
' Keyboard Shortcut: Ctrl+q
'
'This will apply vlookup formula in column C and D
ActiveCell.Select
ActiveCell.FormulaR1C1 = _
"=IF(ISBLANK(RC[-2]),VLOOKUP(RC[-1],master_data!R1C2:R1000C3,2,FALSE),VLOOKUP(sale!RC[-2],master_data!R2C1:R1000C3,3,FALSE))"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISBLANK(RC[-3]),VLOOKUP(RC[-2],master_data!R2C2:R1000C7,6,FALSE),VLOOKUP(RC[-3],master_data!R1C1:R1000C7,7,FALSE))"
ActiveCell.Offset(0, 1).Range("A1").Select
'This is will immediatly prompt input box to enter quantity after the above operation
myValue = InputBox("Enter Quantity")
ActiveCell.Value = myValue
'This will move cursor to the next column for calculation
ActiveCell.Offset(0, 1).Range("A1").Select
'This will calculate the Value of Quantity * Selling price
myMultivalue = "=RC[-2]*RC[-1]"
ActiveCell.Value = myMultivalue
'This will move cursor to the next row, first column
ActiveCell.Offset(1, -5).Range("A1").Select
End Sub