am trying to delete few columns in a pattern.
the pattern is a set of 9 columns; first set is from column Q:Y and my data range spreads till column BVI.
I want to keep the first two columns with column with 15 and delete the next 7 columns from each set.
I have tried the following, but it is extremely slow.
Sub DeleteColumnSlow()
If (MsgBox("Ready to delete columns?", vbYesNo) = vbYes) Then
Dim X As Integer
Dim Mad As Variant
Dim srtC As Variant
Dim EndC As Variant
X = InputBox("number of loops to run")
Mad = 1
srtR = 9
srtC = 19
EndC = 100
Do While (Mad < X)
Set MR = Range(Cells(srtR, srtC), Cells(srtR, EndC))
For Each cell In MR
If cell.Value = "Delete" Then cell.EntireColumn.Delete
Next
Mad = Mad + 1
Loop
MsgBox "update complete, Check updates."
Else: MsgBox "complete sample formatting and then run update"
End If
End Sub
Any help is greatly appreciated.
thanks
Zeema
the pattern is a set of 9 columns; first set is from column Q:Y and my data range spreads till column BVI.
I want to keep the first two columns with column with 15 and delete the next 7 columns from each set.
I have tried the following, but it is extremely slow.
Sub DeleteColumnSlow()
If (MsgBox("Ready to delete columns?", vbYesNo) = vbYes) Then
Dim X As Integer
Dim Mad As Variant
Dim srtC As Variant
Dim EndC As Variant
X = InputBox("number of loops to run")
Mad = 1
srtR = 9
srtC = 19
EndC = 100
Do While (Mad < X)
Set MR = Range(Cells(srtR, srtC), Cells(srtR, EndC))
For Each cell In MR
If cell.Value = "Delete" Then cell.EntireColumn.Delete
Next
Mad = Mad + 1
Loop
MsgBox "update complete, Check updates."
Else: MsgBox "complete sample formatting and then run update"
End If
End Sub
Any help is greatly appreciated.
thanks
Zeema