dassio45
New Member
Hello,
This is my first post on this forum.
I have a large table with data spread across rows and columns. I want to basically create a cross hair when I actively move cells.
I found this VBA code online, it works well but the only problem is that it deletes currently highlighted/colored cells but leaves the Borders as it is when the macro runs on the sheet.
I also have another formula which creates a cross hair using borders rather than highlights but this one deletes the existing borders as you actively move cells BUT leaves the Highlighted/Colored cells in unaffected.
How do I get a solution to either one.
Where I can use a Highlight but it doesn't delete the existing highlighted/colored cells OR
Where I can use a Border but it doesn't delete the existing bordered cells.
MOD EDIT: ADDED CODE TAGS. PLEASE USE CODE TAGS WHILE POSTING CODE.
This is my first post on this forum.
I have a large table with data spread across rows and columns. I want to basically create a cross hair when I actively move cells.
I found this VBA code online, it works well but the only problem is that it deletes currently highlighted/colored cells but leaves the Borders as it is when the macro runs on the sheet.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyRahulDas
Application.ScreenUpdating = False
With Target
.Worksheet.Cells.Interior.ColorIndex = 0
.EntireRow.Interior.ColorIndex = 24
.EntireColumn.Interior.ColorIndex = 20
End With
Application.ScreenUpdating = True
End Sub
I also have another formula which creates a cross hair using borders rather than highlights but this one deletes the existing borders as you actively move cells BUT leaves the Highlighted/Colored cells in unaffected.
Code:
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'Highlight cell
Static xRow
Static xColumn
If xColumn <> "" Then
With Columns(xColumn).Borders
.ColorIndex = xlNone
End With
With Rows(xRow).Borders
.ColorIndex = xlNone
End With
End If
pRow = Selection.Row
pColumn = Selection.Column
xRow = pRow
xColumn = pColumn
With Columns(pColumn).Borders(xlEdgeLeft)
.ColorIndex = 10
.Weight = xlThick
End With
With Columns(pColumn).Borders(xlEdgeRight)
.ColorIndex = 10
.Weight = xlThick
End With
With Rows(pRow).Borders(xlEdgeTop)
.ColorIndex = 5
.Weight = xlThick
End With
With Rows(pRow).Borders(xlEdgeBottom)
.ColorIndex = 5
.Weight = xlThick
End With
End Sub
How do I get a solution to either one.
Where I can use a Highlight but it doesn't delete the existing highlighted/colored cells OR
Where I can use a Border but it doesn't delete the existing bordered cells.
MOD EDIT: ADDED CODE TAGS. PLEASE USE CODE TAGS WHILE POSTING CODE.
Last edited by a moderator: