Formatting Macro Does Runs As Absolute

Alex20850

Board Regular
Joined
Mar 9, 2010
Messages
146
Office Version
  1. 365
Platform
  1. Windows
I am very new to macros. I recorded this macro.
I want to be able click on a cell and then have the highlighting go two to the right and then two down, change the border type and color.
I think I changed the absolute to relative as that being the right thing to do, but
it keeps going back to the same cells.
Here is the mcro.

Sub MakeBlue()
'
' MakeBlue Macro
'
' Keyboard Shortcut: Ctrl+f
'
ActiveCell.Offset(-2, -2).Range("A1:B2").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDash
.ThemeColor = 4
.TintAndShade = 0.599963377788629
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDash
.ThemeColor = 4
.TintAndShade = 0.599963377788629
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDash
.ThemeColor = 4
.TintAndShade = 0.599963377788629
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDash
.ThemeColor = 4
.TintAndShade = 0.599963377788629
.Weight = xlMedium
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Your description ("I want to be able click on a cell and then have the highlighting go two to the right and then two down, change the border type and color") is not foolproof; so let me go with an example:
-if the initial active cell is D10, wich cell/cells has/have to be formatted?

Bye
 
Upvote 0
Your description ("I want to be able click on a cell and then have the highlighting go two to the right and then two down, change the border type and color") is not foolproof; so let me go with an example:
-if the initial active cell is D10, wich cell/cells has/have to be formatted?

Bye

The cells to be formatted would be D10,E10,E11,D11.
 
Upvote 0
Then replace your line ActiveCell.Offset(-2, -2).Range("A1:B2").Select with
Code:
ActiveCell.Range("A1:B2").Select

Bye
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,051
Latest member
excelquestion515

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