Highlight/Fill Multiple cells based on one cells value.

cbc818

New Member
Joined
Feb 17, 2018
Messages
4
Hello Everyone,

Basically I want to show how many people will be needed per station bassed on Cell O16's value. For example if O16 read 8, I would want cells D and E 5-12 to be highlighted. I'm sure this is a simple formula but I'm a neophyte at this.

Thank you!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
try this in the worksheet change event:
Obviously you can choose what formatting you waant to show
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Cells(16, 15)) Is Nothing Then Exit Sub
  If IsNumeric(Target) Then
 Application.EnableEvents = False
       Lastrow = Cells(Rows.Count, "D").End(xlUp).Row
       With Range(Cells(5, 4), Cells(Lastrow, 5)).Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
       End With
       
       With Range(Cells(5, 4), Cells(5 + Target, 5)).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
 Application.EnableEvents = True
  End If
End Sub
 
Upvote 0
This can be done with Excel's built-in Conditional Formatting. The steps would be ..

1. Select from D5 down to E?? (whatever row is at least as many as you would ever want highlighted). In my example below, I selected D5:E30.
2. Home -> Condition Formatting -> New Rule ... -> Use a formula to determine which cells to format -> Format values where this formula is true: =ROWS($D$5:$D5)<=$O$16 -> Format... -> Fill tab -> Choose colour -> OK -> OK

Excel Workbook
DEFO
4
5
6
7
8
9
10
11
12
13
14
15
168
17
CF
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D51. / Formula is =ROWS($D$5:$D5)<=$O$16Abc
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,346
Members
449,155
Latest member
ravioli44

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