| ID | Description | Macro |
| em07 | Show 56 Excel Legacy Colors | em07 Sub ShowLegacy56Colors()
Dim i As Integer
Dim rowNum As Integer, colNum As Integer
' Clear old values in active sheet
Cells.Clear
rowNum = 1
colNum = 1
For i = 1 To 56
' Set cell color using ColorIndex
Cells(rowNum, colNum).Interior.ColorIndex = i
' Display the index number
Cells(rowNum, colNum).Value = i
' Format grid layout (8 columns wide)
colNum = colNum + 1
If colNum > 8 Then
colNum = 1
rowNum = rowNum + 1
End If
Next i
MsgBox "All 56 legacy colors displayed!", vbInformation
End Sub
|
| em06 | Convert selected cell content to absolute values and remove links | em06 Sub ConvertToValuesAndRemoveLinks()
Dim rng As Range
If TypeName(Selection) <> "Range" Then
MsgBox "Please select a range of cells.", vbExclamation
Exit Sub
End If
Set rng = Selection
Application.ScreenUpdating = False
' Convert formulas to static values (breaks internal/external formula links)
rng.Value = rng.Value
' Remove hyperlinks (e.g. web/email links) in the selection
rng.Hyperlinks.Delete
Application.ScreenUpdating = True
MsgBox rng.Cells.Count & " cell(s) converted to values, links removed.", vbInformation
End Sub
|
| em05 | Highlight Row/s as you move from one cell to another | em05 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static prevRow As Range
Dim highlightColor As Long
highlightColor = RGB(255, 255, 153) ' Light yellow
' Restore previous row's formatting (remove highlight)
If Not prevRow Is Nothing Then
prevRow.EntireRow.Interior.ColorIndex = xlNone
End If
' Highlight current row
Target.EntireRow.Interior.Color = highlightColor
' Store current row for next time
Set prevRow = Target
End Sub
|
| em04 | Color PAN Digits in GST Number to Magenta | em04 Sub ColorPANDigitsInGST()
Dim c As Range
Dim txt As String
For Each c In Selection
txt = c.Value
If Len(txt) = 0 Then GoTo NextCell
' Reset entire text to black first
c.Font.Color = vbBlack
' Color characters 8 to 11 magenta (only if cell is long enough)
If Len(txt) >= 11 Then
c.Characters(8, 4).Font.Color = vbMagenta
End If
NextCell:
Next c
End Sub
|
| em03 | Color Text Black and Numbers Magenta for characters within a cell or a range | em03 Sub ColorTextBlackAndNumbersMagenta()
Dim c As Range, i As Long, ch As String
Dim txt As String
For Each c In Selection
txt = c.Value
c.Font.Color = vbBlack ' reset first
' : Other Options vbBlack or vbRed or vbGreen or vbYellow or vbBlue or vbMagenta or vbCyan or vbWhite
For i = 1 To Len(txt)
ch = Mid(txt, i, 1)
If ch Like "[0-9]" Then
c.Characters(i, 1).Font.Color = vbMagenta
ElseIf ch Like "[A-Za-z]" Then
c.Characters(i, 1).Font.Color = vbBlack
End If
Next i
Next c
End Sub
|
| em02 | Delete all objects from every worksheet like Shapes, Pictures, Charts, Form Controls (buttons, dropdowns, checkboxes), SmartArt and OLEObjects | em02 Sub DeleteAllObjects()
Dim ws As Worksheet
Dim shp As Shape
Dim obj As OLEObject
For Each ws In ThisWorkbook.Worksheets
'Delete Shapes
For Each shp In ws.Shapes
shp.Delete
Next shp
'Delete ActiveX Controls
For Each obj In ws.OLEObjects
obj.Delete
Next obj
Next ws
MsgBox "All objects deleted.", vbInformation
End Sub
|
| em01 | Remove Conditional Formatting from all sheets | em01 Sub RemoveConditionalFormatting()
Dim ws As Worksheet
Dim response As VbMsgBoxResult
response = MsgBox("Remove ALL conditional formatting from aLL sheets?", vbYesNo + vbExclamation)
If response = vbYes Then
For Each ws In ThisWorkbook.Worksheets
ws.Cells.FormatConditions.Delete
Next ws
MsgBox "Done.", vbInformation
Else
MsgBox "Operation cancelled.", vbInformation
End If
End Sub
|