Highlight Row/s as you move from one cell to another
PrivateSub Worksheet_SelectionChange(ByVal Target As Range)
Static prevRow As Range
Dim highlightColor AsLong
highlightColor = RGB(255, 255, 153) ' Light yellow' Restore previous row's formatting (remove highlight)IfNot prevRow IsNothingThen
prevRow.EntireRow.Interior.ColorIndex = xlNone
EndIf' Highlight current row
Target.EntireRow.Interior.Color = highlightColor
' Store current row for next timeSet prevRow = Target
EndSub
em04
Color PAN Digits in GST Number to Magenta
Sub ColorPANDigitsInGST()
Dim c As Range
Dim txt AsStringForEach c In Selection
txt = c.Value
If Len(txt) = 0 ThenGoTo 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
EndIf
NextCell:
Next c
EndSub
em03
Color Text Black and Numbers Magenta for text within a cell or a range : Other Options vbBlack or vbRed or vbGreen or vbYellow or vbBlue or vbMagenta or vbCyan or vbWhite
Sub ColorTextBlackAndNumbersMagenta()
Dim c As Range, i AsLong, ch AsStringDim txt AsStringForEach c In Selection
txt = c.Value
c.Font.Color = vbBlack ' reset firstFor 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
EndIfNext i
Next c
EndSub
em02
Delete all objects from every worksheet like Shapes, Pictures, Charts, Form Controls (buttons, dropdowns, checkboxes), SmartArt and OLEObjects
Sub DeleteAllObjects()
Dim ws As Worksheet
Dim shp As Shape
Dim obj As OLEObject
ForEach ws In ThisWorkbook.Worksheets
'Delete ShapesForEach shp In ws.Shapes
shp.Delete
Next shp
'Delete ActiveX ControlsForEach obj In ws.OLEObjects
obj.Delete
Next obj
Next ws
MsgBox "All objects deleted.", vbInformation
EndSub
em01
Remove Conditional Formatting from all sheets
Sub RemoveConditionalFormatting()
Dim ws As Worksheet
Dim response As VbMsgBoxResult
response = MsgBox("Remove ALL conditional formatting from aLL sheets?", vbYesNo + vbExclamation)
If response = vbYes ThenForEach ws In ThisWorkbook.Worksheets
ws.Cells.FormatConditions.Delete
Next ws
MsgBox "Done.", vbInformation
Else
MsgBox "Operation cancelled.", vbInformation
EndIfEndSub