• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

Delete Unhighlighted rows

I have a spreadsheet with over 15,000 rows

I am looking for a macro that will delete any row that is unhighlighted.

Thanks
0
zyanj
Asked:
zyanj
  • 5
  • 3
1 Solution
 
Saqib Husain, SyedEngineerCommented:
How do you highlight/unhighlight a row. Can you upload a sample sheet?
0
 
etech0Commented:
Try this:

sub delete()


dim x as integer
x = 1
do until cells(x,1).value = ""
    if cells(x,1).Interior.Pattern = xlNone then rows(x).delete
    x = x + 1
loop

end sub
0
 
etech0Commented:
(My code tests column A for in each row to check if it is highlighted)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
zyanjAuthor Commented:
etech0,sorry, the macro did not work

attached is my sheet minus my data, thanks Book1.xlsx
0
 
etech0Commented:
Sorry. Try this, where 15000 is the last possible row that needs to be processed.


Sub delete()


Dim x As Integer
x = 1
Do Until x = 15000
    If Cells(x, 1).Interior.Pattern = xlNone Then Rows(x).delete
    x = x + 1
Loop

End Sub
0
 
zyanjAuthor Commented:
did not delete all cell there were several hundred gaps
0
 
etech0Commented:
Try this:

Sub delete()


Dim x As Integer
x = 1
Do Until x = 15000
    If Cells(x, 1).Interior.Pattern = xlNone Then
        Rows(x).delete
    Else
        x = x + 1
    End If
Loop

End Sub
0
 
zyanjAuthor Commented:
perfection
0
 
etech0Commented:
Your welcome!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now