ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Edited Data Imported into Excel (https://www.excelbanter.com/excel-programming/294816-edited-data-imported-into-excel.html)

ExcelMonkey[_111_]

Edited Data Imported into Excel
 
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

--
Message posted from http://www.ExcelForum.com


Dick Kusleika[_3_]

Edited Data Imported into Excel
 
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

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"ExcelMonkey " wrote in message
...
Sorry quick caveat here. I have to delete all the rows prior to "price"
occuring twice. That is, "price" may occur in row 6 and then again in
row 13. I want to delete all the rows prior to the second occurence of
"price".

Thanks


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com