Formatting Macro Does Runs As Absolute

Alex20850

Board Regular
Joined
Mar 9, 2010
Messages
102
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
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,481
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
 

Alex20850

Board Regular
Joined
Mar 9, 2010
Messages
102
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.
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,481
Then replace your line ActiveCell.Offset(-2, -2).Range("A1:B2").Select with
Code:
ActiveCell.Range("A1:B2").Select
Bye
 

Forum statistics

Threads
1,082,151
Messages
5,363,430
Members
400,736
Latest member
Aida

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top