mercredi 26 juillet 2017

Excel VBA: How to clear all contents of multiple worksheets Using a `LCASE` Identifier

Here is the vba I currently have. I am needing it to delete all data in any worksheet that starts with "Demand". The code is running but no data is being deleted. Any help is appreciated!!

Option Explicit

Sub ClearExcelContent()

Dim DemandData As Worksheet

For Each DemandData In ActiveWorkbook.Worksheets

If LCase(Left(DemandData.Name, 6)) = "Demand" Then

DemandData.Rows("2:" & Rows.Count).ClearContents

End If

Next DemandData

MsgBox "All Demand Data has been Deleted from Consolidation Tab"

End Sub

Aucun commentaire:

Enregistrer un commentaire