read.cash Log in
a@amani2765 more from that month

Why the macro doesn't run automatically 1. Why the macro doesn't run automatically Even if the macro is correctly recorded, it will only run if it's placed in the correct module. The Workbook_SheetSelectionChange code must be in the ThisWorkbook module, not in a standard module or worksheet. Otherwise, Excel won't know when to run it. 2. Correct code structure The code is correct for highlighting the selected row. It must be placed in ThisWorkbook like this: vba Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) Sh.Cells.Interior.ColorIndex = xlNone Sh.Rows(Target.Row).Interior.Color = RGB(220, 230, 241) End Sub 3. Why you have to re-enter the code every time you open the file If you save the file as .xlsx, Excel automatically deletes the macros when you close the file. Even if you entered them manually, they will be lost. That's why it's essential to save them as an .xlsm file to preserve the code.

No comments yet

Log in to join in Reading is open to everyone. Replying needs an account.