Delete Rows Of Data In A Macro (looped)

Nov 18, 2009

I receive spreadsheets each month in the same format. It is effectively 6 rows of titles, 7 rows of weekly data, 2 rows of weekly summary, 3 blank rows then it repeats itself with the 6 rows of titles etc... down the page for 8 or so weeks.

I wish to create a (looped) macro that will leave the top set of titles and the 7 rows of weekly data (Mon to Sun) then delete the next 11 rows and so on and so forth to the end. I will then be left with the intro to the dataset followed by a whole months worth of data in continuous format as opposed to weekly summarised sections. But I am stuck as my macro knowledge is basic and I can only record macro's not program VBA.

I can create a macro and manually delete all entries for one spreadsheet but would rather have a code to do this than can run (x) amount of times in case the size of data changes. When it deletes section by section, the cells move up and the row numbers change.

View 3 Replies


ADVERTISEMENT

Looped Transposing Macro

Mar 2, 2007

I work on some High-throughput Projects analyzing biological samples. The software we use for analysis spits out the data into excel. This is all well and good, being mostly automated. However, my issue arises when I get the output data. It's simply one long list of values in a single column. This could potentially be 384 entries. Depending on the parameters of our experiment, I'd like to be able to take a set number of consecutive entries and transpose them to another worksheet. However I don't know how to loop the function to get the specific entries transposed to their specific worksheet. I'm pasting a recorded macro I made to illustrate my point.

Sub HTSoutput1()
'
' HTSoutput1 Macro
' Macro recorded 3/2/2007 by Jack Rosa
'
' Keyboard Shortcut: Ctrl+q
'
Range("B2:B9").Select
Selection.Copy
Sheets("K562").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "2330"

This would have to be repeated for a column that contains 312 entries so that I end up with each destination worksheet containing a 13row x 8col table (or should it be called an array?).

View 9 Replies View Related

Macro To Delete Rows With Same Data

Nov 18, 2005

In the sample below I need a macro that will delete the entire rows
where the data is repeated in a given column---that is, that it would delete
the repeat ones, leaving one of them. In this example, in the first set, all
that should be left are two rows which contain ME22N and MR8M in column E.
ME22N is repeated two more times and those rows need to be deleted.

If I could get a macro that would ask for the column to operate in, that would be
great for other spreadsheets where it would not necessarily be column E.

ABC DE
MACLEOLLynn MacLeodP0040104ME22N
MACLEOLLynn MacLeodP0040104ME22N
MACLEOLLynn MacLeodP0040104ME22N
MACLEOLLynn MacLeodP0040104MR8M

MACLEOLLynn MacLeodP0050006MB0A
MACLEOLLynn MacLeodP0050006MB0A
MACLEOLLynn MacLeodP0050006MB0A
MACLEOLLynn MacLeodP0050006ME21N
MACLEOLLynn MacLeodP0050006ME21N
MACLEOLLynn MacLeodP0050006ME21N.............

View 12 Replies View Related

Macro To Delete Rows With Data

May 6, 2003

I need a macro to delete rows that contain specific data in column A. For example, in the attached spreadsheet below,I need the macro to look for data in rows A1 - A7 (highlighted in yellow) and then delete the rows. The same data occurrs several times in the spreadsheet. The macro will need to delete all rows where this data occurs in column A.

Microsoft Excel - Book2___Running: xl2002 XP :
OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutD9=
ABCDEFGHI1

[Code] .......

View 9 Replies View Related

Macro To Delete Rows With Data Only

Jan 20, 2010

i am in need of a macro to delete the rows with data only which then leave the sheets cleared and ready to use the next day. if i create a macro to clear say fifty rows of data and then tomorrow there could be 75 rows of data and the macro will fail clearing the sheet. if there is a solution can i just say i can create macros but never stepped into them in visual basic to change them, i guess your thinking what do i do if the macro doesn't work. and the answer is indeed yes i delete it and start it from the begining again and again till i get it right.

View 9 Replies View Related

Macro To Extract/insert Data Then Delete Rows

Jul 25, 2008

I am working with a spreadsheet generated from software that keeps track of fuel usage for a large fleet of vehicles. The data comes out looking like the snapshot below.

******** ******************** ************************************************************************>Microsoft Excel - June Fuel Transaction Listing.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutA3=ABCDEFGH3  Transactions for  CUSTOMER ID: 0000CUST7   Sales        4        5        6Product summary for Vehicle ID   00001080       7        8Product Description  Transactions Quantity9        101 Unleaded  3 57.60  GL11        12Hose summary for Vehicle ID 00001080       13Site ID HoseGradeProductTransactions Quantity140001 2113 57.60  GLJune Fuel Transaction Listing [HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name boxPLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


I am trying to get the data into a more convenient format for analysis. I need a macro that will:

1) Take the text "Product summary for vehicle ID 0000****", extract the last 4 digits of the text, and paste it where the 1 is under the Product heading (a10). Those digits are the actual fleet number, and I need to separate them out from the rest of the text. The digits will change for each vehicle, so the macro should just move down the spreadsheet doing the same thing for each instance (the setup you see is repeated for every vehicle).

2) Once the first goal is accomplished, I would like the macro to then go back through and delete every row except for the rows with the pertinent data in them. So this means I would only want one row per vehicle and all rows would line up directly below each other like demonstrated below.

******** ******************** ************************************************************************>Microsoft Excel - June Fuel Transaction Listing.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutA10=ABCDEFGH101080 Unleaded  3 57.60  GL111081 Unleaded  6 84.70  GL121122 Unleaded  5 47.00  GL131182 Unleaded  8 95.80  GLJune Fuel Transaction Listing [HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name boxPLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

View 9 Replies View Related

Macro To Automatically Delete Data And Hide Rows

Dec 20, 2008

I have a spreadsheet that allows room for 35 students per period, but instead of having the teacher manually go in and delete the extra data and hide the rows, I want to create a macro that will do so.

In cell B4 the teacher will enter how many students are in their first period class. (cell C4 for second period, cell D4 for third etc...) I want the entering of the number to automatically hide the superfluous rows and delete the data in the second column for those rows. I don't want the rows to be completely deleted because another year they may have more students and need those rows back.

I have attached one of the workbooks that I need to put this macro into. I have created room for 35 students in a given period. So if they have 23 students entered into B4 (period one) I would need rows 30-41 to be hidden, and I would need the formulas in B30:B41, E30:E41, H30:H31, K30:K31 etc....deleted.

Basically the point of the formulas is the teacher will enter the total points possible on that given assignment in cell B6, E6, H6 etc....and it autofills that score down, so the teacher only enters those that missed points instead of entering in the missed ones and the 100 percent ones.

I would need those formulas to be deleted because if the assignment was out of 10 then cell B30-B41 will give students a 10, and then the class average will be computing those scores,but those students don't exist.

But if I can't get the macro to auto delete the formulas, I will just not have those formulas in there, and the teacher can enter all scores.

View 9 Replies View Related

Macro To Split Data Into Three Different Sheets / Tabs - Delete Blank Rows

Jul 30, 2013

I'm pasting a lot of data into a spreadsheet and then using a macro to split the data into three different sheets/tabs. I'm doing this by simply copying entire columns. Each sheet/tab has a headings row and autofilters added so that my boss can filter on certain manufacturers in one of the columns.

The problem is that when he selects a manufacturer, at the bottom left corner of the screen it shows the number of records, which at the moment will be something like "6 of 65211".

The actual sheet only has a few hundred rows (not 65211). So how do I delete all the blank rows beneath my data using a macro or vba code?

As an extra point, I'd like to use column B to check for blank rows (not column A).

View 6 Replies View Related

Macro To Delete If Set Of Multiple Rows Equals Another Set Of Rows

May 10, 2012

I need a macro that can look at multiple (say three) rows and delete those rows if they match another three rows in the worksheet.

For example:

1 0
3 1
5 7
4 4
6 5
8 3
1 8
5 2
3 9
6 5
8 3
1 8
7 5

If three rows are the same, then one set is deleted (it can be either bottom or top set). I would like to do this for rows 1-500 in the worksheet.

View 1 Replies View Related

Delete Rows: Macro Skips Rows

Nov 5, 2006

Need to solve my problem in the thread "Type Mismatch Error Message". Now a new problem has come up in the same code, so - according to the rules - I've started a new thread. (This one is most likely due to my poor knowledge of VBA syntax).

Sub Delete_invalid_rows()
Dim i%, j%
Dim Nr%, valid As Boolean, BYPdata As Boolean
Dim ar1 As Variant
Dim ar2 As Variant
Dim ar3 As Variant
Dim ar4 As Variant
Nr = 20
ar1 = Array(11, 14, 19, _
20, 22, 25, 26, 27, 28, 29, _
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, _ .................

View 2 Replies View Related

Moving Data From Rows To Columns And Delete Repeated Rows

Apr 16, 2014

removing duplicate rows and move other data frm rows to columns.xlsx.

I am attaching a sample excel sheet showing what I need to do.In the first tab, I have a list that includes duplicate rows (first column only). I want to remove those duplicate rows but I don't want to lose the data in the following columns which can be unique or duplicates as well.

see the desired result tab in the sheet to get an idea of what I am looking for as the end result.

Keep in mind that the actual source file I am working with could have up to 50000 row, and the expected results could be around 2000 rows. So nothing can be done manually.

View 5 Replies View Related

Creating Looped If Statement

Nov 22, 2012

I am working on creating a looped if statement but can not get it working.

I have 3 columns:

D3:D50 = Application ID
G3:G50 = Sorted
H3:H50 = PasteCreate

Column D contains unique records, however the first 6 characters could be the same so I have used the Left statement (=LEFT(D3,6)) to sort by this in column G.

Application ID

Sorted
PasteCreate

ES0920.21

ES0920

[Code] .........

What I want it to do is to go through the list and Match the first 6 characters of cells in coloumn D:D create a new worksheet and name it the first 6 characters then copy (in the case above it would create 2 new worksheets that would be called ES0920 and ES1341.

ES0920 would have all the ES0920... names pasted into cells A2:R2 and ES1341 would have the 2 ES1341... names pasted into A2 and B2

The list of EStext will continually change. but will always contain ES followed by 6 or more numbers.

View 3 Replies View Related

Macro To Delete Last Two Rows

Mar 26, 2009

i wrote this macro and want to delete last two rows on active sheet this macro.

Sub deleteLast2Rows()
With ThisWorkbook.Worksheets(1)
Dim rowNum As Integer
Dim m As Range
rowNum = 2
Set m = .Range("A" & rowNum)
rowNum = rowNum - 2

EntireRow.Delete
End With
End Sub

View 2 Replies View Related

Delete Rows Macro ..

Oct 2, 2008

I have a huge spreadsheet that I want to be able to sort through and delete the unwanted rows. I want to do a search for anything in column C that equals 2225 including the next row after and delete the rest. Here is an example...

View 3 Replies View Related

Macro- To Delete Any Rows

May 22, 2007

I recorded this macro but I need it to delete any Rows that have the word "Normal" in column F

Sub Count()
'
' Count Macro
' Macro recorded 5/22/2007 by pricci
'

'
Sheets("Alarm Log").Select
Sheets("Alarm Log").Copy After:=Sheets(2)
Sheets("Alarm Log (2)").Select
Sheets("Alarm Log (2)").Name = "Count"
Cells.Select
Selection.Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

View 9 Replies View Related

Want To Delete Rows Using Macro

Sep 10, 2007

I want to delete the rows if in "Column L" value is "Yes".

View 9 Replies View Related

Macro To Delete Certain Rows ...

Dec 19, 2007

macro to delete certain rows from a sheet based on the value of a cell?

I'm tryin to get it so if the value in "F" is NOT 150, 151, 152, 153, 154, then i want that row deleted.

this should leave me with data that contains either 150 - 154 in column F.

View 9 Replies View Related

Macro To Delete The Rows

Jul 1, 2008

I have a table of data A2:H1000 (this gets longer every week). Within that data every so often i have a row which is blank from A:G, but has a value in H.

I want to create some code that checks the rows and if the cell A in the row is blank, to delete the entire row.

View 9 Replies View Related

Macro Delete The Rows

Sep 19, 2008

If I have a table (see below), is it possible to create a macro to delete rows that do not have defined data. In the example below, I would want to delete rows 4 through 7 as there is no date in Columns B through D.

A B C D
1 2008 100 200 300
2 2009 500 600 700
3 2010 800 900 1000
4 2010
5 2011
6 2012
7 2013

View 9 Replies View Related

Delete Empty Rows Macro?

Apr 18, 2014

I have a formula that does exactly what I need , it fetches negative stocks from sheet 1 , but the formula places the data exactly on the same row where the negative is , thus there are a lot of in between data not required , Yes I can copy paste special values and remove blank rows , but the macro will do it faster

View 13 Replies View Related

Macro To Delete Rows Containing Certain Text

Jan 15, 2009

I have put together a macro that will delete rows (called DeleteUnwantedRows) in a spreadsheet that contain the phrases "no further action" and "not applicable" ... However the macro does not appear to be working.

View 2 Replies View Related

Macro To Delete Rows With A Condition

May 28, 2009

What I need is a macro to delete a row or rows for a specific range of cells (eg. E20 to E58) when the cells in that range column E is = blank. The cells in column E is formated with a currency sign $. Deleting the row should shift up all rows below. I need to run this macro manually. Excel 2002 SP3.

View 9 Replies View Related

Macro To Delete Rows And Sort

Sep 27, 2009

I have attached a worksheet to illustrate a "Before" (raw data) and "After" (desired results).

Each row contains data on a forex trade. The variables which must be assessed in each row are:

Currency Pair (e.g. GBP/USD).
Opening Time
Closing Time

What I need to do is delete many rows in the raw data because they reflect a condition I do not want in my analysis, which is having multiple open trades of a single currency pair during the same time period.

To perform my analysis I need to delete all trades (rows) which meet the above condition.

The worksheet provides examples, along with a rudimentary tool I've used to help me sort/delete rows manually.

Since I am looking at thousands of trades, a manual sort/delete is impractical. (my eyes don't like this kind of work!)

The rudimentary tool I've used in manual sorts/deletes is simply to have a column which returns a "1" if a trade opens before an older trade has closed. I do this by first sorting the data by (a) currency pair then (b) date opened. Then I must manually go through multiple iterations of deleting trades until there all of the "1's" have disappeared.

I'm hoping someone can show me a macro which might do this sorting/testing/deleting automatically, at least to the point where all I have to do is repeatedly press a "macro" button until there are no "1's"

View 8 Replies View Related

Macro To Delete Rows Containing All Zeros

Oct 19, 2009

I have a daily worksheet that will always have 9 columns. The end of the data contains some rows that contain all zeros. The number of rows will vary from day to day. Is there a way to specify that "if the cells in columns A:I contain a zero, delete the entire row"?

View 4 Replies View Related

Delete Rows And Column Macro

Aug 1, 2011

I want to create a Macro to be used on the Active Sheet that FIRST deletes all the rows that contain the following values in Column E. Here are the values contained in Column E that will result in deleting the whole row: PT, JK, BH.

Here is a data sample, the real data will have thousands of rows:

ROW 1 COLUMN E ROW 2 Work Code ROW 3 BN ROW 4 KL ROW 5 PT ROW 6 JK
ROW 7 AL ROW 8 BH ROW 9 PT ROW 10 JK ROW 11 TU ROW 12 PT

Second, I would like the Macro to DELETE the ENTIRE Column E Not just the values in Column E.

View 5 Replies View Related

Macro To Delete Variable Rows

Jan 4, 2012

I am creating a macro to tidy up a large data sheet. it is a list of products as follows:

Heading1Code; Heading2date; etc
12
12
12

13
13

14

15
15
15

The blanks beneath each series of products need to be deleted but they are variable and a macro that i write is not flexible enough to remove a variable number of blank rows beneath a variable number of each product.

View 9 Replies View Related

Macro To Delete Blank Rows

Nov 13, 2012

I would like VBA code to delete all rows where there are blanks in Col B

View 2 Replies View Related

Macro To Delete Rows Outside Of A Range

Nov 20, 2012

I have a large workseet that I want to Delete all rows where value in column Q is > 9.99 and < 60.00. So the only rows left would be where column Q value is < 9.99 and > 59.99. (deleting out the middle amounts) I think this might be a nested If stmt but have not figured it out so I'm not sure if there is another way.

View 4 Replies View Related

Run Macro To Delete All Rows (except For First 2) In A Table?

Apr 30, 2013

I need to run a macro to delete all the rows (except for the first 2) in a table. The table is named "Table1". The problem is the tables size is always different. Is there a way in VBA where I can resize the table to the original size?

View 2 Replies View Related

Macro To Delete Selected Rows

Feb 13, 2007

I can use Find to find all all my rows where there is an "X" in a cell, and delete all the rows found that way (even if they are separated by other rows) in one fell swoop -MANUALLY. I use Find after having limited the area to be searched with a named array (so other "X's" don't get involved).

But when I record a macro with all the same moves, NONE of the Find code appears in the macro AT ALL....just the delete command. Hello? Relative reference (on the record macro toolbar) seems to have no impact.

So....the mission here is to delete entire rows wherever an "X" has been entered in a certain cell to mark the row for deletion...and those X's get there either through a DV list OR by a cell below the DV copying down the X from the DV cell above.

This is so because sometimes rows are "sub" to the one above, and if the one above is marked for deletion, then so must be the rows sub to it.

I have found this seemingly simple for...next loop here on the board:

For a = 1 To 50
If Cells(a, 17) = "x" Then
Rows(a).Select
Selection.EntireRow.Delete
Next a

But the debugger reports a "next" without a "for" which is obviously there in dark blue as I suppose it should be.

If I could make this puppy work, I would sooner have it start from A2 and then go down from there to the last row -wherever that happens to be.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved