Hi, lottidotti,
why donīt you use the approach of splitting the string?
I had to work a bit on the code as I use a non-englisch version of Excel:
Sub Clear_Individual_Rows()
'
' Clear_Individual_Rows Macro
'
Dim varRowsToClear As Variant
Dim varArray As Variant
Dim lngCounter As Long
varRowsToClear = Application.InputBox("Enter the Rows to Clear separated by comma", "Clear Rows", "8,11,23", Type:=1 + 2)
If varRowsToClear = False Then Exit Sub
varArray = Split(varRowsToClear, ",")
For lngCounter = 0 To UBound(varArray)
If Val(varArray(lngCounter)) < 8 Then
MsgBox "Wrong line detected", vbExclamation, "Macro aborted"
Exit Sub
End If
Next lngCounter
If MsgBox("Are you sure you want to Clear these ROWS " & vbLf & varRowsToClear & " ?", vbYesNo + vbInformation) = vbYes Then
varArray = Split(varRowsToClear, ",")
On Error Resume Next
For lngCounter = 0 To UBound(varArray)
Application.Intersect(Range("a:bg"), Rows(varArray(lngCounter))).ClearContents
Next lngCounter
On Error GoTo 0
End If
'
End Sub
Maybe another idea could be to lock rows 1 to 7 and use a code like
With ActiveSheet
.EnableSelection = xlUnlockedCells
.Protect contents:=True, UserInterfaceOnly:=True
End With
to avoid Rows 1:7 to be selected at all.
Ciao,
Holger
Bookmarks