How can i Deleting rows with specific criteria?

General discussion on MS Excel and its spreadsheets.

How can i Deleting rows with specific criteria?

Postby Joseph S. Klein » Tue May 06, 2014 6:17 am

Hi, I have written a macro that combines sheet1 of all workbooks within a folder into one worksheet. I now need to figure out how to delete all of the headers (there are all the same), except for the 1st one, as well as all of the rows where column D is blank. Any suggestions? Thank you.
Joseph S. Klein
 
Posts: 38
Joined: Mon Mar 24, 2014 6:28 am

Re: How can i Deleting rows with specific criteria?

Postby Tansenn » Thu May 08, 2014 7:46 am

Hi,
the number of workbooks that will be combined will change each time the user has to use it, so I would not be able to delete headers by counting them. Since all of the headers are exactly the same, I was hoping to have a code that would look for all of the rows that are equal to the first one and delete all of them, excluding the first one.
Thanks
Tansenn
 
Posts: 28
Joined: Tue Mar 25, 2014 6:27 am

Re: How can i Deleting rows with specific criteria?

Postby JackSMT » Thu May 08, 2014 7:48 am

I did wind up using a different code since the value in column A would be the same in all of the headers. I just used:

Sub Delete Repeated Header()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If Range("A" & i).Value = "PLANID" Then Rows(i).Delete
Next i
End Sub
Thanks
JackSMT
 
Posts: 20
Joined: Tue Mar 25, 2014 6:29 am


Return to MS Excel- Help Forum

Who is online

Users browsing this forum: No registered users and 0 guests

cron