how can I check for cell focus inside a spreadsheet ?

G

Guest

I'm trying to do some "Conditional Formatting" of a range of cells if any
cell in that range is focused on.

example, assuming I've built a payroll spreadsheet, and I'm using rows 2
though 7, (columns A through M).

A2:A7 the list of employee names
B2:B7 the emploee pay rate,
C2:C7 the number of hours the employee worked,
etc., etc until M2:M7 which shows the employees NET wages.

When I focus on any cell within a row, (click in a cell), I want to set up
conditional formatting that will effect all the cells within that row.
(Basically, if I focus in D4, I want cells A4-M4 (the entire row) to have a
solid green pattern with BOLD white text. Then, IF I click in L5, I want
A4-M4 to back to its normal formatting and row A5-M5 to assume the solid
green pattern with BOLD white text.)
 
P

Peo Sjoblom

Only by using an event macro would this be possible
Personally I think it is a bad idea
 
G

Guest

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Cells.Font.Bold = False
Cells.Font.ColorIndex = 1

Set r = Target.EntireRow

r.Interior.ColorIndex = 10
r.Font.Bold = True
r.Font.ColorIndex = 2
End Sub

Put this in the Worksheet code area, not a standard module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top