macro

chazzerman01

Board Regular
Joined
Nov 18, 2019
Messages
65
does anyone know a macro code that will highlight the whole row that the cursor is on. im using it to make it easier to read values in a table
 
I know. Nobody mention that there is any hardcoded fill inside.
You were right that first solution was not so good because it clearing existed CFs.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
There might not be any hard fill in the cell, quite often important details don't get mentioned because people don't always realise that they will be relevant to the suggestions that will be offered.

I offered a suggestion similar to yours in an old thread, problems arose there because of pre-existing formats.

I prefer your methods for the visibility that is offered, but using selection to highlight the row is less likely to conflict with anything else.

It might be possible to add and remove single conditions from a range without affecting existing rules. If that can be done then I think that it would be the 'winning' method.
 
Upvote 0
Absolutely agree. As in 99,9% there is no enough details in OPs posts.
Usually I try to give the simplest solution. Obviously, it can interfere or damage on sheet but due to lacking of details, as above, it can't be predicted.
I never said that your macro is wrong or works incorrect.
 
Upvote 0
@KOKOSEK is it possible so that when the highlighted row goes over a row that already has coloured boxes, that instead of resetting the boxes to no fill it keeps the colour that was originally there
 
Upvote 0
It is but what if you got lots of hardcoded colouring in row ?
Ex. col A, col. D, col. AA, col. FD ? It need to be kept to reverse it back.
If you want to 'highlight' active row maybe you can consider other way like bolding fonts (I believe that you've got something in rows) or something else.
 
Upvote 0
1574258323288.png

basically this is my table, I just want it so that when you move the cursor it temporarily highlights the cells in that row until you move the cursor but when I used your code it changed all the colours to no fill, but if it's possible I'd like it to keep the original colour of the table
 
Upvote 0
What you don't want to use Jasonb75's solution?
 
Upvote 0
Try like this. Make the same colouring of column in row 100 000, what's no colour, no colour, in E/F/G/H/I make a colour as in your table.
Check range IMHO you do not need colouring full row (A:XFD) so set range A:O in code below:
Then:
Code:
Public OldTarget As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
    
    On Error Resume Next
    For Each cell In Range(Cells(OldTarget.Row, "A"), Cells(OldTarget.Row, "O"))     ' set range
        cell.Interior.Color = Cells(100000, cell.Column).Interior.Color
    Next cell
   
    Range(Cells(Target.Row, "A"), Cells(Target.Row, "O")).Interior.Color = RGB(255, 255, 0)    'set the same range as above
    Set OldTarget = Target
End Sub
probably could be done better and more efficient but it works.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

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