Senso
Inventaris
- Lid geworden
- 13 jun 2016
- Berichten
- 11.642
- Besturingssysteem
- W10 Pro en W11 Pro
- Office versie
- Office 2007 H&S en Office 2021 Prof Plus
Ik wil de constanten (alleen getallen) selecteren op de actieve sheet en deleten via een macro.
Wie wil deze macro schrijven.
Ik kom niet verder dan:
Wie wil deze macro schrijven.
Ik kom niet verder dan:
PHP:
Sub DeleteConstantsOnSheet()
' Define the worksheet you want to work with (e.g., ActiveSheet or Sheets("SheetName"))
Dim ws As Worksheet
Set ws = ActiveSheet ' or Set ws = Sheets("Your Sheet Name")
' Check if there are any constants to clear
If Application.CountA(ws.Cells) > 0 Then
' Select only cells that contain constants (not formulas)
On Error Resume Next ' In case no constants are found, prevent an error
ws.Cells.SpecialCells(xlCellTypeConstants, 23).ClearContents
On Error GoTo 0 ' Resume normal error handling
MsgBox "All constants have been deleted from " & ws.Name & ".", vbInformation, "Done"
Else
MsgBox "The sheet " & ws.Name & " is already empty.", vbInformation, "Info"
End If
End Sub
Laatst bewerkt: