Macro to remove rows?

Hi,

I receive thousands of rows of data from an extract that comes from a
database. The data extract automatically generates page headers that
need to be removed, and I would love to automate this process.

The headers do have a pattern to them, but I'm not clever enough to
figure out a good way to use that to write a macro.

The first row of the header starts with hyphens
-------------------------------
Then there's a variable number of rows of header data to delete
followed by another row of hyphens
-------------------------------
Then 2 additional rows that must be deleted.

The number of rows between the headers is not a constant, which makes
no sense to me, but there you go.

Any help would be greatly appreciated!
0
Non.Atall (9)
5/29/2009 7:32:20 PM
excel 39880 articles. 2 followers. Follow

5 Replies
1076 Views

Similar Articles

[PageSpeed] 19

Bad,

Can you post a sample of the first few characters from a typical
header section and a few data rows?

You may be able to use brute force and just sort the records and
delete or omit the garbage - if the data you want to keep is
numerical.

Patrick

On May 29, 3:32=A0pm, Bad at VBA <Non.At...@gmail.com> wrote:
> Hi,
>
> I receive thousands of rows of data from an extract that comes from a
> database. The data extract automatically generates page headers that
> need to be removed, and I would love to automate this process.
>
> The headers do have a pattern to them, but I'm not clever enough to
> figure out a good way to use that to write a macro.
>
> The first row of the header starts with hyphens
> -------------------------------
> Then there's a variable number of rows of header data to delete
> followed by another row of hyphens
> -------------------------------
> Then 2 additional rows that must be deleted.
>
> The number of rows between the headers is not a constant, which makes
> no sense to me, but there you go.
>
> Any help would be greatly appreciated!

0
arkins (4)
5/29/2009 7:41:15 PM
Hi Patrick,

Actually, the data I want to keep is text. The header rows are similar
to:

-----------------------------------------------------------
Report
                     Grand Count:  4139
User                xxxx
Date                 20090529
data    20090401 to 20090430
more data
                     more data
                     sometimes more data sometimes less
Some info
---------------------------------
|Heading names
|--------------------------------
This is text I would want to keep here
More text to keep

I hope that is helpful!

On May 29, 12:41=A0pm, PatrickA <ark...@toast.net> wrote:
> Bad,
>
> Can you post a sample of the first few characters from a typical
> header section and a few data rows?
>
> You may be able to use brute force and just sort the records and
> delete or omit the garbage - if the data you want to keep is
> numerical.
>
> Patrick
>
> On May 29, 3:32=A0pm, Bad at VBA <Non.At...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I receive thousands of rows of data from an extract that comes from a
> > database. The data extract automatically generates page headers that
> > need to be removed, and I would love to automate this process.
>
> > The headers do have a pattern to them, but I'm not clever enough to
> > figure out a good way to use that to write a macro.
>
> > The first row of the header starts with hyphens
> > -------------------------------
> > Then there's a variable number of rows of header data to delete
> > followed by another row of hyphens
> > -------------------------------
> > Then 2 additional rows that must be deleted.
>
> > The number of rows between the headers is not a constant, which makes
> > no sense to me, but there you go.
>
> > Any help would be greatly appreciated!

0
Non.Atall (9)
5/29/2009 7:59:47 PM
Oh, and just to be clear, there will be somewhere between 50 and 60
rows of data that I want to keep, then a repeat of the header. The
headers are consistent in a single download, but the number of rows
they take up varies from month to month.



On May 29, 12:59=A0pm, Bad at VBA <Non.At...@gmail.com> wrote:
> Hi Patrick,
>
> Actually, the data I want to keep is text. The header rows are similar
> to:
>
> -----------------------------------------------------------
> Report
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Grand Count: =A04139
> User =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xxxx
> Date =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 20090529
> data =A0 =A020090401 to 20090430
> more data
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0more data
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sometimes more data sometimes =
less
> Some info
> ---------------------------------
> |Heading names
> |--------------------------------
> This is text I would want to keep here
> More text to keep
>
> I hope that is helpful!
>
> On May 29, 12:41=A0pm, PatrickA <ark...@toast.net> wrote:
>
>
>
> > Bad,
>
> > Can you post a sample of the first few characters from a typical
> > header section and a few data rows?
>
> > You may be able to use brute force and just sort the records and
> > delete or omit the garbage - if the data you want to keep is
> > numerical.
>
> > Patrick
>
> > On May 29, 3:32=A0pm, Bad at VBA <Non.At...@gmail.com> wrote:
>
> > > Hi,
>
> > > I receive thousands of rows of data from an extract that comes from a
> > > database. The data extract automatically generates page headers that
> > > need to be removed, and I would love to automate this process.
>
> > > The headers do have a pattern to them, but I'm not clever enough to
> > > figure out a good way to use that to write a macro.
>
> > > The first row of the header starts with hyphens
> > > -------------------------------
> > > Then there's a variable number of rows of header data to delete
> > > followed by another row of hyphens
> > > -------------------------------
> > > Then 2 additional rows that must be deleted.
>
> > > The number of rows between the headers is not a constant, which makes
> > > no sense to me, but there you go.
>
> > > Any help would be greatly appreciated!

0
Non.Atall (9)
5/29/2009 8:18:06 PM
Hi,

You probably won't get a response because your sample data is unclear.  
Please try to post a sample of the data set not a stylized approximation.  

For example

------
Header1
Header2
Header3
------
Age   FName    LName
34     xxx          yyyy
54     aaa          bn
-------
Header4
Header5
Header6
---------
and so on...

It is not at all clear from your sample which lines are headers and which 
not.  

-- 
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Bad at VBA" wrote:

> Hi Patrick,
> 
> Actually, the data I want to keep is text. The header rows are similar
> to:
> 
> -----------------------------------------------------------
> Report
>                      Grand Count:  4139
> User                xxxx
> Date                 20090529
> data    20090401 to 20090430
> more data
>                      more data
>                      sometimes more data sometimes less
> Some info
> ---------------------------------
> |Heading names
> |--------------------------------
> This is text I would want to keep here
> More text to keep
> 
> I hope that is helpful!
> 
> On May 29, 12:41 pm, PatrickA <ark...@toast.net> wrote:
> > Bad,
> >
> > Can you post a sample of the first few characters from a typical
> > header section and a few data rows?
> >
> > You may be able to use brute force and just sort the records and
> > delete or omit the garbage - if the data you want to keep is
> > numerical.
> >
> > Patrick
> >
> > On May 29, 3:32 pm, Bad at VBA <Non.At...@gmail.com> wrote:
> >
> >
> >
> > > Hi,
> >
> > > I receive thousands of rows of data from an extract that comes from a
> > > database. The data extract automatically generates page headers that
> > > need to be removed, and I would love to automate this process.
> >
> > > The headers do have a pattern to them, but I'm not clever enough to
> > > figure out a good way to use that to write a macro.
> >
> > > The first row of the header starts with hyphens
> > > -------------------------------
> > > Then there's a variable number of rows of header data to delete
> > > followed by another row of hyphens
> > > -------------------------------
> > > Then 2 additional rows that must be deleted.
> >
> > > The number of rows between the headers is not a constant, which makes
> > > no sense to me, but there you go.
> >
> > > Any help would be greatly appreciated!
> 
> 
0
5/30/2009 4:20:01 PM
I can do that!  Any row that has hyphens or says Header I need to
remove.

-----------------------------------------------------------
Header
Header
Header
Header  (The number of header rows in this section varies)
Header  (But it is always set off by hyphen rows)
Header
Header
Header
Header
---------------------------------
Header
|--------------------------------
Age   FName   LName
43     xxx         xxx
22     xxx         xxx
(usually about 50 - 60 rows of real data before the next header
sequence starts)
-----------------------------------------------------------
Header
Header
Header
Header  (The number of header rows in this section varies)
Header  (But it is always set off by hyphen rows)
Header
Header
Header
Header
---------------------------------
Header
|--------------------------------
Age   FName   LName
43     xxx         xxx
22     xxx         xxx

On May 30, 9:20=A0am, Shane Devenshire
<ShaneDevensh...@discussions.microsoft.com> wrote:
> Hi,
>
> You probably won't get a response because your sample data is unclear. =
=A0
> Please try to post a sample of the data set not a stylized approximation.=
 =A0
>
> For example
>
> ------
> Header1
> Header2
> Header3
> ------
> Age =A0 FName =A0 =A0LName
> 34 =A0 =A0 xxx =A0 =A0 =A0 =A0 =A0yyyy
> 54 =A0 =A0 aaa =A0 =A0 =A0 =A0 =A0bn
> -------
> Header4
> Header5
> Header6
> ---------
> and so on...
>
> It is not at all clear from your sample which lines are headers and which
> not. =A0
>
> --
> If this helps, please click the Yes button.
>
> Cheers,
> Shane Devenshire
>
>
>
> "Bad at VBA" wrote:
> > Hi Patrick,
>
> > Actually, the data I want to keep is text. The header rows are similar
> > to:
>
> > -----------------------------------------------------------
> > Report
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Grand Count: =A04139
> > User =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xxxx
> > Date =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 20090529
> > data =A0 =A020090401 to 20090430
> > more data
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0more data
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sometimes more data sometime=
s less
> > Some info
> > ---------------------------------
> > |Heading names
> > |--------------------------------
> > This is text I would want to keep here
> > More text to keep
>
> > I hope that is helpful!
>
> > On May 29, 12:41 pm, PatrickA <ark...@toast.net> wrote:
> > > Bad,
>
> > > Can you post a sample of the first few characters from a typical
> > > header section and a few data rows?
>
> > > You may be able to use brute force and just sort the records and
> > > delete or omit the garbage - if the data you want to keep is
> > > numerical.
>
> > > Patrick
>
> > > On May 29, 3:32 pm, Bad at VBA <Non.At...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I receive thousands of rows of data from an extract that comes from=
 a
> > > > database. The data extract automatically generates page headers tha=
t
> > > > need to be removed, and I would love to automate this process.
>
> > > > The headers do have a pattern to them, but I'm not clever enough to
> > > > figure out a good way to use that to write a macro.
>
> > > > The first row of the header starts with hyphens
> > > > -------------------------------
> > > > Then there's a variable number of rows of header data to delete
> > > > followed by another row of hyphens
> > > > -------------------------------
> > > > Then 2 additional rows that must be deleted.
>
> > > > The number of rows between the headers is not a constant, which mak=
es
> > > > no sense to me, but there you go.
>
> > > > Any help would be greatly appreciated!

0
Non.Atall (9)
5/31/2009 3:49:52 PM
Reply:

Similar Artilces:

removing reference to other workbook
hi i have a excel wookbook which contains references to other workbook. whenever i open this wookbook it asks me for updating the link to the other workbook. i want to remove these references to other workbook but am not able to figure out which cell is refering to the other workbook. i also have lot of references in the same workbook. i dont want the internal references to be removed. can anyone help me to accomplish this task. any help is highly appretiated. thankx in advance. pradyumna Hi try the following add-in to find/delete links: http://www.bmsltd.ie/DLCount/DLCount.asp?file=FindL...

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

deleting rows #4
In microsoft encell 2000 when i delete a row (say row 5) the row disapears but so does the row number then all other rows are moved up is there a way to delete the row and keep the number 5? The row number shouldn't disappear unless you are hiding the row, not deleting it -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Doctorpc631" <doctorpc631@aol.com> wrote in message news:e4FaNYV4EHA.1260@TK2MSFTNGP12.phx.gbl... > In microsoft encell 2000 when i delete a row (say row 5) the row > disapears > but s...

Removing old email attachments
Is there a way to have Outlook automatically remove attachments from old emails in personal and public folders (ie any email older than [90] days would have the attachment(s) removed from the email). Any help would be appreciated. ...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Removing Duplicate Values
Hello all I have a column of data made up of 100 cells. Some cells have a unique value and others the same value. Using a formula in another column, is there a way I can be left with just a list of unique values e.g. if X comes up 3 times in the original column how can I show it just once in another? I know I can use remove duplicates in excel but I don't want to as I don't want to have to use macros thanks -- James. Hi, take a look to CPearson web http://www.cpearson.com/excel/Duplicates.aspx at the end of the page there is a link as well theat will ...

Copying a variable nuimber of rows
I want to copy the most recent 10 rows (excluding the header row) from worksheet A to worksheet B. My problem is how do I define a variable number of rows if there are fewer than 10 lines completed? I do not want to copy any blank lines. I am fairly new to VBA and am struggling to work out the code for this so any help will be gratefully appreciated. John Try With Activesheet LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row if LastRow > 10 Then FirstRow = LastRow - 9 Else FirstRow = 1 EndIf ...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

User removed Anonymous permission from Calendar...how to get it back
A user has deleted the Anonymous permissions from their calendar and I am unable to find a way to get it back. Does anyone know what can be done to add this back to their calendar. TIA In news:Xns9861A9314BAB8bobarcabca@207.46.248.16, Fuzzy Logic <bob@arc.ab.caREMOVETHIS> typed: > A user has deleted the Anonymous permissions from their calendar and > I am unable to find a way to get it back. Does anyone know what can > be done to add this back to their calendar. TIA In that user's Outlook, right-click on Calendar, properties, permissions tab. Add Anonymous, and do whate...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

Changing Rows to Columns
Is it possible to easily rotate a spreadsheet or part of a spreadshet, to change the data in rows to columns? Do to a sorting problem in the charts I create, it seems I have to sort the data in the spreadsheet first. Any help would be appreciated. Hi, Sure is a way. select & copy your data. then select the cell where you want to re-paste; right-click and select paste special; in the dialog box check "transpose". Ok. jeff >-----Original Message----- >Is it possible to easily rotate a spreadsheet or part of a >spreadshet, to change the data in rows to columns? D...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Cannot insert new rows
I am running excel 2007 and I have 23 worksheets in a workbook. I have no links or hidden rows or colums. My biggest sheet is A1: AW8096. I use VB macros to add lines and move data from one set of workbooks to this one. I have built several sheets using this proceedure. All of a sudden I get the error "Cannot shift objects off sheet" when I run a routine I have 50,000 times. I have checked to make sure there are no hidden comments, row or columns. I have deleted most of the worksheets and I still get the error. I have made copies of the workbook and used different file ...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Archive command does not remove anything
We have not tried to archive since installing exchange 2003 Trying to get users in a good habit I put a warning message to tell people to start archiving to a .pst file on there local machine, It does not work for any one, this feature was fine when we used to use microsoft mail with everyones mail on their own .pst files. We click file then archive and the icon shows in the lower right corner that it is doing something but nothing leaves the inbox and no copies of messages appear in the archive folders. There are no error messages. It looks like the process has worked but nothing hap...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

Turn off auto adjust of row heights
I have a complex spreadsheet for my catalogue of products. I have set row heights, fonts and sizes of texts for different rows. Every now and then my row heights are automatically changed by EXCEL. I have turned off word wrap I have locked/protected my sheet. How can I stop EXCEL automatically readjusting row heights at its discretion. Thanks ...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...

Inserting Rows
Hi, I have 500+ rows of data that I would like to insert a blank row in between each row. Is there a globabl way of doing it rather than having to click on each row one at a time and then selecting 'insert row'? Thanks Ben Hi Ben have a look at http://tinyurl.com/2pt5r Frank Ben wrote: > Hi, > > I have 500+ rows of data that I would like to insert a > blank row in between each row. Is there a globabl way of > doing it rather than having to click on each row one at a > time and then selecting 'insert row'? > > Thanks > > Ben Thanks...

Footer Macro?
Hi Months ago I read a Public Sub Macro that read the selection of a drop down list in a combo box and placed it in the center Footer at the same time it also placed the date in the right Footer and tme in the left footer. I have searched most of the regular sites including this one and cannot find it anywhere --- Can anyone help with my search. Any help much appreciated Cheers ---- Mully ...