vba code needed for filling a row when a cell is selected that row

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
821
Office Version
  1. 365
Platform
  1. Windows
I have had to cut off my row and column headers due to a monitor only being 13" wide. If possible I need to see if there is code that can be inserted into the sheet that will simply fill that entire Row yellow when there is a cell selected in that Row.When another Row is selected it will fill it yellow and return the previously selected one back to no fill.... Thanks as always:)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Are you set on VBA code? What if you simply split the windo and freeze panes? That way column and row headers remain visible when you scroll through the worksheet.

My daughter goes to Troy State.
 
Upvote 0
yes i really need the code to do it for me. I think i may can use conditional formatting but I havent found the right formula.. Troy State is a awesome college, I had a family member that went there........
 
Upvote 0
Try this code by pasting it in the worksheet module. It doesn't have the functionality you asked for, but it should be close.

The code highlights the row if you double click in column A. To turn the highlighting off, you must double click column A again.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
With Target
Dim rng1 As Range
If .Row < 3 Or .Column > 1 Then Exit Sub
Set rng1 = Target.EntireRow

If rng1.Interior.ColorIndex = 6 Then
rng1.Interior.ColorIndex = 0
Else
rng1.Interior.ColorIndex = 6
End If

Cancel = True
End With
End Sub
 
Upvote 0
Works good , I think I can work with that.I noticed you had a color index=6, were is that index located on a computer? Thanks
 
Upvote 0
I found the right color index by trial and error. Sorry!

There are other ways of setting the color. I think the statment below works(not tested)

Range.Interior.Color = RGB(0,0,0)

Excel has predefined colors that are enumerated, e.g; rgbAqua. Search RGB in the object browser.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

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