Forum Discussion
Felicity123
Oct 07, 2021Brass Contributor
Need a macro to remove duplicate header rows but leave selected rows at the top
I have a very large data output file (approx 30k rows) that contains repeated headers and blank rows. Can anyone help with a macro that lets me select which rows to keep at the top and removes all d...
- Oct 09, 2021Thank you so much! This is gold!! I tested it using A1:C1 with E1:F1 as well and it works perfectly.
This is also much, much quicker than using the 2 short macros I had been using and much more flexible being able to select the cells rather than have the value hardcoded into the macro.
Regarding importing html files, do you have a solution to automate that? The main issue here is I need an input box where I can select the location of the file that will be converted because this will vary.
(I realise that should probably be a separate post)
Thanks so much for your help! I really appreciate it!
Logaraj Sekar
Oct 08, 2021Iron Contributor
Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+q
'
Range("G4").Select
Selection.End(xlDown).Offset(1, 0).Select
If Len(ActiveCell.Offset(0, -6)) = 314 Then
Do While Len(ActiveCell.Offset(0, -6)) = 314
Range(Selection, ActiveCell.Offset(3, 0)).EntireRow.Select
Selection.Delete Shift:=xlUp
Range("G4").Select
Selection.End(xlDown).Offset(1, 0).Select
Loop
ElseIf Len(ActiveCell.Offset(0, -6)) <> 314 Then
MsgBox "Finished"
End If
End SubFelicity123 As per file sent by you. Try this on your file.
Felicity123
Oct 08, 2021Brass Contributor
Thank you for your reply. I see your logic but this does not delete any rows in my file - only result I am getting from it running it is the Msgbox.