Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, Newbie here and looking for a macro code to delete the header off a
report. This report is multiple pages long and have imported into Excel. Obviously every 60 rows or so, the report header shows up again. I wish to delete the header and was hoping to build a macro to do that. Wanted it to match the characters "RPS677" which is the first 6 characters of the string and then once it matches that, then delete the next 7 rows (including the one with the RPS677 in it). Below is an example of the report. I am putting R1-R12 to show the seperate rows. Those numbers are not part of the original spreadsheet R1 2051619 127 119 09:51 119 14:51 00025 00142 R2 DREAS DCAJT R3 RPS677 BATCH STATUS OPERATOR REPORT R4 SORTED BY BOX NUMBER AND BATCH NUMBER R5 DEPOSIT JULIAN DATE: 121 R6 ------------------------------------------ R7 BOX BAT PREP DATA ENTERED R8 NUMBER NBR JUL TIME JUL TIME COUNT KEY R9 OPERATOR OPERATOR R10 -------------------------------------------- R11 2051619 128 119 09:51 119 15:16 00025 00138 R12 DREAS DCAJT I want to delete R3-R10 and was hoping to use the RPS677 as the criteria to find that row, then delete the next 7. This would bring the row with "2051619 128" up to R3. I can only match the first few characters of the RPS677 string because at the end of that string it a page number, which changes with each page. Any help would be appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Test()
Dim iLastRow As Long Dim i As Long Dim nCalculation With Application .ScreenUpdating = False nCalculation = .Calculation .Calculation = xlCalculationManual End With iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 1 Step -1 If Left(Cells(i, "A"), 6).Value = "RPS677" Then Rows(i).Resize(7).Delete End If Next i With Application .Calculation = nCalculation .ScreenUpdating = True End With End Sub -- HTH Bob Phillips (remove xxx from email address if mailing direct) wrote in message oups.com... Hi, Newbie here and looking for a macro code to delete the header off a report. This report is multiple pages long and have imported into Excel. Obviously every 60 rows or so, the report header shows up again. I wish to delete the header and was hoping to build a macro to do that. Wanted it to match the characters "RPS677" which is the first 6 characters of the string and then once it matches that, then delete the next 7 rows (including the one with the RPS677 in it). Below is an example of the report. I am putting R1-R12 to show the seperate rows. Those numbers are not part of the original spreadsheet R1 2051619 127 119 09:51 119 14:51 00025 00142 R2 DREAS DCAJT R3 RPS677 BATCH STATUS OPERATOR REPORT R4 SORTED BY BOX NUMBER AND BATCH NUMBER R5 DEPOSIT JULIAN DATE: 121 R6 ------------------------------------------ R7 BOX BAT PREP DATA ENTERED R8 NUMBER NBR JUL TIME JUL TIME COUNT KEY R9 OPERATOR OPERATOR R10 -------------------------------------------- R11 2051619 128 119 09:51 119 15:16 00025 00138 R12 DREAS DCAJT I want to delete R3-R10 and was hoping to use the RPS677 as the criteria to find that row, then delete the next 7. This would bring the row with "2051619 128" up to R3. I can only match the first few characters of the RPS677 string because at the end of that string it a page number, which changes with each page. Any help would be appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the quick response. I am getting a run-time error '424' :
Object required. When I go to debug, it's stopping at the "If Left(Cells(i, "A"), 6).Value = "RPS677" Then" part of the code. Any words of advice? Thanks in advance |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the quick response. I am getting a run-time error '424' :
Object required. When I go to debug, it's stopping at the "If Left(Cells(i, "A"), 6).Value = "RPS677" Then" part of the code. Any words of advice? Thanks in advance |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Syntax wrong
Sub Test() Dim iLastRow As Long Dim i As Long Dim nCalculation With Application .ScreenUpdating = False nCalculation = .Calculation .Calculation = xlCalculationManual End With iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 1 Step -1 If Left(Cells(i, "A").Value, 6) = "RPS677" Then Rows(i).Resize(7).Delete End If Next i With Application .Calculation = nCalculation .ScreenUpdating = True End With End Sub -- HTH Bob Phillips (remove xxx from email address if mailing direct) wrote in message oups.com... Thanks for the quick response. I am getting a run-time error '424' : Object required. When I go to debug, it's stopping at the "If Left(Cells(i, "A"), 6).Value = "RPS677" Then" part of the code. Any words of advice? Thanks in advance |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works like a charm. I appreciate your help!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete rows based on certain criteria | Excel Discussion (Misc queries) | |||
use macro to insert characters at the beginning of a string | Excel Programming | |||
Column Delete based on String | Excel Programming | |||
Delete characters from a string | Excel Programming | |||
Cut and Paste macro based on criteria then delete empty rows | Excel Programming |