ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Cleaning forms (https://www.excelbanter.com/excel-discussion-misc-queries/134177-cleaning-forms.html)

Lost in Microbiology

Cleaning forms
 
I have an imported text file from a lab system that has a header every 51 rows.

I would like to create a macro that deletes 6 rows every 51 rows, but can't
figure it out, please help. Thanks.

Zone[_2_]

Cleaning forms
 
You mean there are 6 heading rows in every 51 rows? Are the heading rows
the same distance apart throughout the file? Is there anything unique about
the heading rows (such as text in a column that normally has numbers)?

"Lost in Microbiology" wrote
in message ...
I have an imported text file from a lab system that has a header every 51
rows.

I would like to create a macro that deletes 6 rows every 51 rows, but
can't
figure it out, please help. Thanks.




Lost in Microbiology

Cleaning forms
 
Zone,

Correct, every at row 52 there are 6 consecutive rows that need to be
deleted. They have a title, the first column always starts out "REPORT
TYPE...."
The heading rows are the same distance throughout.

Thanks for your help


"Zone" wrote:

You mean there are 6 heading rows in every 51 rows? Are the heading rows
the same distance apart throughout the file? Is there anything unique about
the heading rows (such as text in a column that normally has numbers)?

"Lost in Microbiology" wrote
in message ...
I have an imported text file from a lab system that has a header every 51
rows.

I would like to create a macro that deletes 6 rows every 51 rows, but
can't
figure it out, please help. Thanks.





Dave Peterson

Cleaning forms
 
If "Report Type" doesn't appear in any other cell except that header, then you
could use:

Option Explicit
Sub testme()

Dim myStr As String
Dim FoundCell As Range
Dim wks As Worksheet

Set wks = ActiveSheet

'* means there could be text following
'report type
myStr = "report type*"

With wks.Range("a:A")
Do
Set FoundCell = .Cells.Find(what:=myStr, _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'no more to fix
Exit Do
Else
FoundCell.Resize(6, 1).EntireRow.Delete
End If
Loop
End With
End Sub

Lost in Microbiology wrote:

Zone,

Correct, every at row 52 there are 6 consecutive rows that need to be
deleted. They have a title, the first column always starts out "REPORT
TYPE...."
The heading rows are the same distance throughout.

Thanks for your help

"Zone" wrote:

You mean there are 6 heading rows in every 51 rows? Are the heading rows
the same distance apart throughout the file? Is there anything unique about
the heading rows (such as text in a column that normally has numbers)?

"Lost in Microbiology" wrote
in message ...
I have an imported text file from a lab system that has a header every 51
rows.

I would like to create a macro that deletes 6 rows every 51 rows, but
can't
figure it out, please help. Thanks.





--

Dave Peterson


All times are GMT +1. The time now is 04:21 PM.

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