Forum Discussion
Excel
Jun 04, 2021Iron Contributor
Reptitive Header in VBA
Hello Everyone, I have written VBA code and it works perfectly. But i press RUN button multiple times so it repeat headers in evry sheet. So, how to revert it back with the help of VBA coding? ...
- Jun 04, 2021
Yes:
Public Sub CleanUpData() Dim i As Integer i = 1 Do While i <= Worksheets.Count Worksheets(i).Select Do While Range("A2").Value = "REGION" Range("A2").EntireRow.Delete Loop If Range("A1").Value <> "REGION" Then AddHeaders FormatHeaders End If i = i + 1 Loop End Sub
Excel
Jun 04, 2021Iron Contributor
Sir,
If Range("A1").Value <> "REGION" Then
means that it prevent from coming multiple header..
Right sir?
Can we delete repititive header with the help of VBA code?
If Range("A1").Value <> "REGION" Then
means that it prevent from coming multiple header..
Right sir?
Can we delete repititive header with the help of VBA code?
HansVogelaar
Jun 04, 2021MVP
Yes:
Public Sub CleanUpData()
Dim i As Integer
i = 1
Do While i <= Worksheets.Count
Worksheets(i).Select
Do While Range("A2").Value = "REGION"
Range("A2").EntireRow.Delete
Loop
If Range("A1").Value <> "REGION" Then
AddHeaders
FormatHeaders
End If
i = i + 1
Loop
End Sub
- ExcelJun 04, 2021Iron ContributorThank you so much sir😊😊