Forum Discussion
rebekah_mcmaster
Oct 21, 2024Copper Contributor
So confused why / how to automate my vba macros?
Hello, new to VBA's and I'm honestly muddling through things. I am trying to learn and thought I would make my own To Do list where the main sheet "ToDo" has a drop down option in column A (star...
HansVogelaar
Oct 21, 2024MVP
It is possible to do that, but I would not recommend it. It would be very confusing if a row is whisked away the moment enters or selects Q1 in a cell in column A. It also makes it difficult to undo a mistake.
Instead, I would run the macro when (1) the workbook is opened, and (2) when the sheet with the data is deactivated (for example when you activate the Q1 sheet).
To do so:
(1) Right-click the sheet tab of the ToDo sheet and select 'View Code' from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Deactivate()
Call MoveRowsToQ1
End Sub
(2) Still in the Visual Basic Editor, double-click ThisWorkbook in the project explorer pane on the left hand side.
Copy the following code into the ThisWorkbook module:
Private Sub Workbook_Open()
Call MoveRowsToQ1
End Sub