Format cells in range based on value in cell below?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
270
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to find a quick way to avoid having to manually do this.

I have a row of cells, for example, A894 - FF894. What I'd like to do is look at A895 and if it isn't blank then in cell A894 add a double bottom border. Then move onto cell B895, if it isn't blank then add a double bottom border to B894. And so on through the range.

Any help appreciated and thank you for reading.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You said: What I'd like to do is look at A895
Do you mean select?
No script can run when you just look at a cell and does the formatting stay in the cell when you select the next range or do you only want the formatting when the cell is the active cell?
 
Upvote 0
Hello, a VBA demonstration for starters :​
VBA Code:
Sub Demo1()
        Dim Rc As Range
        Application.ScreenUpdating = False
    For Each Rc In [A895:FF895]
        If Not IsEmpty(Rc) Then Rc.Borders(8).LineStyle = xlDouble
    Next
        Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Hi TheWennerWoman,

I'm not sure if this is what you want, and you can only format a single line border, so here's my attempt using Conditional Formatting.

TheWennerWoman.xlsx
ABCDE
894x
895xxx
896
897xx
898x
899
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A894:FF999Expression=A895<>""textNO
 
Upvote 0
Sub Demo1() Dim Rc As Range Application.ScreenUpdating = False For Each Rc In [A895:FF895] If Not IsEmpty(Rc) Then Rc.Borders(8).LineStyle = xlDouble Next Application.ScreenUpdating = True End Sub
Excellent, many thanks, works a treat!
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

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