I'm attempting to make a Macro that takes data from fixed cells in another sheet that I update and inputs the data into another sheet. Everyday I put new data into the source sheet and it will be transferred into the second sheet as that days data (one row). This requires the original cell I run the macro from to be the fixed point of reference. How do I reset the active cell the cell that I hit the Macro keystroke from?
I have tried Startcell = activecell or things of that type but they have not yielded results. I'm not good with VBA so it could have been a formatting error that resulted in this not working.
Sub Macro15()
'
' Macro15 Macro
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
Sheets("MACRO (insert data)").Select
Range("G4:Q4").Select
Selection.Copy
Sheets("Jun-2019").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("MACRO (insert data)").Select
Range("W4:AG5").Select
Selection.Copy
Sheets("Jun-2019").Select
Range("C42").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("O10:Y10").Select
Selection.Copy
Startcell.Offset(0, 11).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
If someone could help me just return the active cell to the start cell after "Range("O10:Y10").Select" and "Selection.Copy" that would be great.
<your_variable_name>.Select
Related: Avoid Activate/Select wherever possible. None of your macro actually requires anything to be Selected, so this is an X/Y problem: you desire to return the initial selection, but that's only because you're altering the selection needlessly during runtime :) – David ZemensDim startRange as Range
and thenSet startRange = ActiveCell
– David Zemens