Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Conditionally format Thick Border


Hello All
I need help wirting a macro to conditionally format a selection based
on the below criteria. The macro will run at the click of a button.

Selection(B2:F18)

If $A2="Y1" then format Border top thick and Interior color light
Yellow

If $A2="Y" then format Border top thin and Interior color light Yellow

If $A2="G1" then format Border top thick and Interior color light
Green

If $A2="G" then format Border top thin and Interior color light Green

Thank you for your help!
Ed


--
nuver
------------------------------------------------------------------------
nuver's Profile: http://www.excelforum.com/member.php...o&userid=10036
View this thread: http://www.excelforum.com/showthread...hreadid=473648

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Macro to Conditionally format Thick Border

Maybe like this:

Sub Frmt()
With Range("B2:F18")
Select Case Range("A1").Value
Case "Y1"
.Borders(xlEdgeTop).Weight = xlThick
.Borders(xlInsideHorizontal).Weight = xlThick
.Interior.ColorIndex = 36
Case "Y"
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlInsideHorizontal).Weight = xlThin
.Interior.ColorIndex = 36
Case "G1"
.Borders(xlEdgeTop).Weight = xlThick
.Borders(xlInsideHorizontal).Weight = xlThick
.Interior.ColorIndex = 35
Case "G"
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlInsideHorizontal).Weight = xlThin
.Interior.ColorIndex = 35
End Select
End With
End Sub

Hope this helps
Rowan

nuver wrote:
Hello All
I need help wirting a macro to conditionally format a selection based
on the below criteria. The macro will run at the click of a button.

Selection(B2:F18)

If $A2="Y1" then format Border top thick and Interior color light
Yellow

If $A2="Y" then format Border top thin and Interior color light Yellow

If $A2="G1" then format Border top thick and Interior color light
Green

If $A2="G" then format Border top thin and Interior color light Green

Thank you for your help!
Ed


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Conditionally format Thick Border


Thanks Rowan
Works exactly as I asked. The problem is I did not ask the questio
correctly. The formatting is what I am looking for but the source an
destination are not exactly what I wanted. I am going to try to explai
myself a little better, sorry I did not get it right the first time
Thanks for the quick response.

If cell A2 meets the criteria I want the formatting to pertain t
B2:F2
If cell A3 meets the criteria I want the formatting to pertain t
B3:F3
If cell A4 meets the criteria I want the formatting to pertain t
B4:F4
If cell A5 meets the criteria I want the formatting to pertain t
B5:F5

and so on....

Thanks again

--
nuve
-----------------------------------------------------------------------
nuver's Profile: http://www.excelforum.com/member.php...fo&userid=1003
View this thread: http://www.excelforum.com/showthread.php?threadid=47364

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Macro to Conditionally format Thick Border

I am still not 100% clear on what you require but if you are wanting to
check the value of each cell in the range A2:A18 and set the formating
in columns B:F in each row based on that value then maybe like this:

Sub Frmt()
Dim cell As Range
For Each cell In Range("A2:A18")
With Range(Cells(cell.Row, 2), Cells(cell.Row, 6))
Select Case cell.Value
Case "Y1"
.Borders(xlEdgeTop).Weight = xlThick
.Interior.ColorIndex = 36
Case "Y"
.Borders(xlEdgeTop).Weight = xlThin
.Interior.ColorIndex = 36
Case "G1"
.Borders(xlEdgeTop).Weight = xlThick
.Interior.ColorIndex = 35
Case "G"
.Borders(xlEdgeTop).Weight = xlThin
.Interior.ColorIndex = 35
End Select
End With
Next cell
End Sub

Regards
Rowan

nuver wrote:
Thanks Rowan
Works exactly as I asked. The problem is I did not ask the question
correctly. The formatting is what I am looking for but the source and
destination are not exactly what I wanted. I am going to try to explain
myself a little better, sorry I did not get it right the first time.
Thanks for the quick response.

If cell A2 meets the criteria I want the formatting to pertain to
B2:F2
If cell A3 meets the criteria I want the formatting to pertain to
B3:F3
If cell A4 meets the criteria I want the formatting to pertain to
B4:F4
If cell A5 meets the criteria I want the formatting to pertain to
B5:F5

and so on....

Thanks again!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to Conditionally format Thick Border


Rowan
This is exactly what I was looking for. Thank you for your help.


--
nuver
------------------------------------------------------------------------
nuver's Profile: http://www.excelforum.com/member.php...o&userid=10036
View this thread: http://www.excelforum.com/showthread...hreadid=473648



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Macro to Conditionally format Thick Border

You're welcome

nuver wrote:
Rowan
This is exactly what I was looking for. Thank you for your help.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting - Thick Border? fedude Excel Worksheet Functions 6 February 23rd 10 03:28 PM
thick border on 2nd half of print dlw Excel Discussion (Misc queries) 0 October 4th 08 04:12 PM
conditionally format anumber format Montana Excel Worksheet Functions 5 January 15th 08 05:25 PM
How to offset cell value from thick border lines? [email protected] Excel Discussion (Misc queries) 3 November 23rd 06 07:51 PM
Conditionally format Terri Excel Programming 1 November 15th 04 08:06 PM


All times are GMT +1. The time now is 10:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"