Highlight Row and Column VBA

SRMPURCHASE

Board Regular
Joined
Dec 23, 2014
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
After years of successful use, once a cell is selected the row and column are highlighted, works fine until recently I have to hit F9 to enable the macro.
What would cause this F9 requirement when in the past I have not needed it, the highlighting simply followed my cell selections.


Private Sub Workbook_Open()
End Sub
Sub EnableEvents()
Application.EnableEvents = 1
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Run this code:

VBA Code:
Sub EnableEvents()
Application.EnableEvents = 1
End Sub

Update this:
VBA Code:
Private Sub Workbook_Open()
  Call EnableEvents
End Sub
 
Upvote 0
I deleted the first two lines of my code, inserted yours and I still need F9 to highlight row/col.
 
Upvote 0
But you have to run this macro once:
VBA Code:
Sub EnableEvents()
Application.EnableEvents = 1
End Sub

Go back to the sheet and try.
--------------------------------

Update your codes so that they look like this:

VBA Code:
Private Sub Workbook_Open()
  Call EnableEvents
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
  Application.ScreenUpdating = True
End Sub

Sub EnableEvents()
  Application.EnableEvents = 1
End Sub
 
Upvote 0
I still need to press F9 to get the row/col highlight to change.
 
Upvote 0
How is your conditional formatting?
Can you share your file?

You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
here's the CF behind that macro, macro range is B24:BE1953

=OR(AND(CELL("col")=CELL("col",B24),CELL("row")>CELL("row",B24)),AND(CELL("row")=CELL("row",B24),CELL("col")>CELL("col",B24)))+$A$1:$H$1
 
Upvote 0
Works for me.

It looks to me like you haven't run this macro:
VBA Code:
Sub EnableEvents()
  Application.EnableEvents = True
End Sub

Or
You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
Here's what I have in the tab under View Code now.
Working on getting a sharable link from my One Drive, not as easy as I would like.


Sub EnableEvents()
Application.EnableEvents = 1
End Sub


Private Sub Workbook_Open()
Call EnableEvents
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I don't know how to explain it, but you have to run this macro:

VBA Code:
Sub EnableEvents()
  Application.EnableEvents = True
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (EnableEvents) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,178
Latest member
Emilou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top