Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Dynamic border to the table based on dates

0

Hi

I have a table of data with product details. I want to draw a border to the rows (group of rows) based on date.

Thanks
KSK

Answer
Discuss

Discussion

Did you see my Answer? 
John_Ru (rep: 6152) Jul 13, '23 at 6:32 am
Add to Discussion

Answers

0

Hi KSK and welcome to the Forum.

You can use Conditional Formatting to do that...

In the attached revised  file, I've applied outer borders only to your Raw Table Data. Then I've added a Conditional Formatting rule which draws a red bottom border "dynamically" when the date changes e.g. change cell F9 to 02/07/2023 and the red bottom border will jump to row 8.

I used the following method :

Firstly select cell F4 then go menu Home, ribbon Styles and click Conditional Formatting/New Rule... then click Use a formula...

In the requestor, under Format values... paste:

=IF(AND($F4<>"", OR(F5="",$F4<$F5)), 1, 0)

(this gives a 1 -True- when the cell in column F isn't nothing and the cell below is a higher value or blank).

Click Format... then choose the Border tab, click bottom line in Border box (I also chose a red line colour), click OK.

In New Formatting requestor, click OK

Nothing seems to happen but go Home/Styles/ Conditional Formatting/Manage Rules... then carefully change Applies to from

 =$F$4

 (paste over) to:

=$F$4:$K$50

(it could be =$F$4:$K$30 but I extended it past the table range to show the rule doesn't create borders outside the table).

Click Apply (or Okay) and a red bottom border will extend into columns F:K when the date in F changes (the $F in the formula does that).

If you really want to, you could devise rules to set the left and right borders (I leave that to you). If you want to learn more, look in the Tutorials section, you'll find lessons on Conditional Formatting.

Hope this fixes your problem. If so, please be sure to mark this Answer as Selected.

Discuss

Discussion

KSK. What is your response please?

I spent my own time answering your question so it would be nice if you spent a fraction of that time replying. 
John_Ru (rep: 6152) Jul 15, '23 at 5:24 pm
If it helps, this gave me some ideas !!
SusanUser (rep: 16) Jul 24, '23 at 1:42 pm
Haha, thanks Susan! I'm pleased it helped you. Sadly all too often a user asks for help but then fails to respond to a working answer so it just feels like I just wasted my personal time. 
John_Ru (rep: 6152) Jul 24, '23 at 1:55 pm
Not sure why the last message was repeated 3 times (now deleted) 
John_Ru (rep: 6152) Jul 24, '23 at 1:57 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login