Edited Data Imported into Excel

  • Thread starter Thread starter ExcelMonkey
  • Start date Start date
E

ExcelMonkey

I have a sheet which imports data. The data that gets imported is no
spaced evenly. I want to be able to delete all the rows prior to th
row that the word "Price" occurs in. That is, if A13 says "Price",
would like to delete rows 1 to 12. "Price" only occurs in the Colum
A.

The problem I am having is that "price" is not occuring every 13 rows.
It varies in the data. I was originally deleting the first 12 row
within a loop but realized the uneven spacing of data was causing m
problems.

Thank-you
 
EM

Try this

Sub DelRows()

Dim cell As Range
Dim FirstPrice As Boolean

FirstPrice = False

For Each cell In Range("A1:A50")
If cell.Value = "Price" Then
If FirstPrice Then
Range("a1", cell.Offset(-1, 0)).EntireRow.Delete
Exit For
Else
FirstPrice = True
End If
End If
Next cell

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top