Find Data And Delete Remaining Rows (For Each Loop)

Apr 24, 2009

In the code below I find rows containing "$$ #" at the far left and process it.
For all the remaining rows I want to delete the entire row, my macro only deletes some rows. Obviously I am not grasping something about looping throught the rows to delete unwanted data.

View 2 Replies


ADVERTISEMENT

Find The Next NULL Value And Delete Remaining Column

Feb 4, 2010

I am paste valuing from one sheet to another. The size of the data changes each time so to manually delete all Null cells is a pain.
If I do not delete them it sucks up 3 megs of space. I have searched the board several times looking for a solution, lots of discussions but no solutions.
It would be great if I could find that first cell that contains the Null string and then delete the cells remaining in the column. Any suggestions would be greatly appreciated.

View 9 Replies View Related

Scan The Rows And Find The Last Remaining Row

Aug 31, 2009

I can't figure out the specific way to write a Do Until where it exits once there is no more text in any further rows.

Basically scan the rows and find the last remaining row. If there is no data after 20 rows then exit the loop.

This is a sample.

A
B
C
D


F
G
H


I
J

I would want it to understand that there is no information after "J" and to exit the loop.

View 36 Replies View Related

Store Row Number Within Loop And Delete All Stored Rows After Loop?

Sep 11, 2013

I have working code that returns a row number within a for loop based on parameters I set.

Each time the for loop runs I would like to store this row number, then after the loop has finished, delete all stored rows.

Code:
for rowNum = 1 to x (some variable end row number which I already have worked out using End(xlUp).Row)
if x = y then
*storedRow = rowNum
end if
next rowNum
*

Lines with a * are the bits I can't work out. I've been trying to understand arrays by reading posts on what other people have done, but I can't fit (or fully understand) the reDims, or reDim preserves into my code. I've seen what appear to be quite complex ways involving uBounds and LBounds, but unfortunately I can't see how to use them.

All I want is to simply keep adding a row numbers to a variable, (i.e. row 2, 5, 20, 33, 120, etc) and then delete those specific rows.

View 4 Replies View Related

Macro To Clear Row Data Then Shift Remaining Data Up To Empty Rows?

Apr 15, 2014

I'd like to have a sheet with multiple columns of data (say A thru K for instance.). Id like to reserve column A for ONLY imputing an X. The rest of the columns b-K would have data in the cells. I'd like to have a macro that when it saw an X in column A, would copy all of the data in cells B-K in that row, paste it into the next empty row of a second sheet (for history tracking), then go back to the original sheet and continue looking for additional "X"'s and repeat. Once all of the X's were copied, it would "clear" (Not delete because some of the cells would have formulas in them that would need to remain for future use.) the cells based on the "X" then finally move all of the remaining data up to the empty rows to fill in the empty rows. This last piece would be more for esthetics to have a clean looking sheet.

View 1 Replies View Related

Find Rows Containing Specific Data And Delete

Jan 5, 2010

I have a large report that I pull each month listing which products we sold last month. There are certain products I don't want included in the report. Until I can have the report re-written, I'm looking for a macro or a function that will find all the rows that contain these product numbers in column M and delete the entire row. The product numbers I need to delete are always the same, but some months one or more of them might not be in the report if they weren't sold.

In Summary:

Find in column M the product numbers:
c1000
316140a
316140
316295a
316295
316311a
316311
316451a
316451
316450a
316450
316452a
316452

Delete those rows containing the product numbers above

View 6 Replies View Related

Find Rows Containing Specific Data And Delete?

Feb 28, 2014

create a VBA to delete rows if the cell doesn't have "Other".

The data is in Column C which consist of the below data so I like VBA to delete the rows when the cell doesn't have "Other"..

-Primary
-Business
-Home
-(blank)
-Other

View 5 Replies View Related

Find The Last Row Without Data In Columns E And F And Delete The 10 Rows Below Them

Mar 14, 2008

I'm trying to come up with a formula to find the last row without any data in columns E and F and delete the 10 rows below them. Is there a way to do this?

View 3 Replies View Related

VBA Loop And Delete 15 Rows

Sep 10, 2013

I have output from mainframe that is copy/paste to an excel workbook. I need to have VBA loop and delete the 15 rows. This is mainframe output so it will always be 15 rows

Count
Campus
Name
Course
Start Date

1
336001
Student1
1
9/2/2003

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

View 1 Replies View Related

VBA Code - Loop Through And Delete Rows

Oct 12, 2013

I use this code to delete some rows, how I would modify it to work in another spreadsheet where it would "Loop" through and delete rows that start with "User:Kellcyna" down to where the rolls start with "Numbers", and delete the rolls that start with "Total cost center" down to where the rolls start with "Numbers".

The data can contain up to 50000 rolls at times.

Sub Finally()
Application.ScreenUpdating = True
[a:a].AutoFilter Field:=1, Criteria1:="="
[a2:a65536].SpecialCells(xlVisible).EntireRow.Delete
If [a1] = "" Then [1:1].Delete
ActiveSheet.AutoFilterMode = False
[Code] ........

Here is a sample of the data I need the macro to work on. The rows I need deleted are the rows that are highlighted.

User: Kellcyna STANDARD HOURS BY COST CENTER Date: 09/29/2013 Time: 15:10:04 Page: 10

Comments:

Order Op Emp Post Work ctr Setup Unit Planned Earned Total Actual Actual Actual Total Total Orde C R

# Date SU Unit Plnd Stds Setup Run Tme Brd Tme Prod Run Time E

104527059 0010 00000000 09/25/2013 HSW01 0.000 0.4 HR 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 PP01

104523849 0010 00000000 09/25/2013 HSW01 0.000 0.2 HR 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 PP01

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

View 5 Replies View Related

Delete Rows, Formatting, Loop

May 15, 2009

1. Delete all data after row 51.
2. Find the average cost (column 4) and delete all rows where the cost is below average. Thus only retaining rows with an above average cost.
3. Then I want to conditionally format any number in column 6 which appears more than three times.
4. I want to loop this through all worksheets in my workbook.

View 9 Replies View Related

Loop Over Rows And Delete Row If Value Not In Table

Aug 11, 2006

I have two worksehets. The first worksheet contains data on products. The product code is in column A. My second sheet contains a list of product codes in column a. I want to delete all rows in worksheet 1 where the product code doesnt exist in the list in worksheet 2. Can someone provide a outline for a macro to loop over sheet one and look up the value in worksheet 2 and delete the row from worksheet 1?

View 3 Replies View Related

Find And Delete Depending On Answer To Msgbox Then Continue Loop

Jun 5, 2012

I am trying to build a macro that will search a column for the word "TEST" and when it finds that word it needs to prompt the user with a YesNo message box (or something similar) if they would like to delete the entire row that contains TEST. If Yes is selected, it should delete the row and continue on to find the next TEST in the column and repeat this process. If the user selects No, it should continue on to find the next TEST in the column and repeat this process.

View 4 Replies View Related

How To Delete Columns And Then Add Column Header To Remaining Ones

May 15, 2014

So I want to add some VBA Code that deletes specified columns and then insert Bolded Column headers to the remaining columns. The columns I want deleted are D,F,I,J,K. For simplicity purposes, the column headers would be A,B,C,D,E,F,G.

I tried using Columns("D,F,I,J,K").delete but I kept on getting 13 error.

[Code] ......

Attached File : Test VBA File.xlsx‎

View 3 Replies View Related

Delete Over 3000 Rows In Worksheet Without A Loop

Nov 15, 2008

I have anywhere from 3000 to 10000 rows to delete in a a number of worksheets, but would like to avoid using a loop as even with onscreen update turned to off like this:

View 3 Replies View Related

Macro To Delete Mutliple Rows On A Loop

May 20, 2009

I need to be able to run a macro that will find the word “report“ within a cell in column A. Once found it I then need it to delete that row, the row above and then the 9 rows underneath it. Once it has deleted that data I need it to then move to the next and so on.

It’s a report I have dropped into excel which repeats the page header. E.g the following is repeated constantly which I need to be deleted:

¬¬¬¬¬¬¬¬¬¬¬¬¬
Report: xxx
Company: xxx
Turnover By C
01/04/2008 To
**THIS REPORT
Customer: 0 T
¬¬¬¬¬¬¬¬¬¬¬¬¬
Account
Cust Num
¬¬¬¬¬¬¬¬¬¬¬¬¬

View 14 Replies View Related

Loop To Delete Rows If Middle Column Less Than 1

Nov 20, 2012

What I have is 3 columns, all containing numbers

What I want to do is delete a row if the middle column is less than 1.

However my loop seems to skip a row if the column data is like the below

a
b
c

1
1
1

1
0
1

1
0
1

1
1
1

1
0
1

End

Code:
Range("A2").Select
Do
If ActiveCell.Offset(0, 1) < 1 Then
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.Delete Shift:=xlUp
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Value = "End"

View 5 Replies View Related

Delete 5 Rows With Loop Without Throwing Up Error?

Dec 31, 2012

I have some code that is working great except that it throws up an error on the last run through because it doesn't find any more rows to delete. I've tried "On Error GoTo" but it doesn't catch it. It seemed to work on my home computer which is running Excel 2010 but then on Excel 2007 I get the debug screen and I don't want that to show up for other users that I share the code with.

Sub DeleteHeaders()
Dim lastrow As Integer
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row

[Code]....

View 3 Replies View Related

Delete Empty Cells And Shift Remaining Left

Oct 7, 2008

I am looking for a method which would delete empty cells in a row, and then shift the remaining data to the left (filling the cells with data). I know that this could be done manually, but I need it completed for 3000 rows! I have attached a simple sheet to show what I'm Looking for.

View 2 Replies View Related

Loop Rows To Find A String

Aug 21, 2009

I have an Excel workbook that i need to loop through all rows searching for a certain string we can call "Totals". There are more than one, and i need to grab the values from each at an offset in the same row, different column, to total at the bottom. I have tried a few things unsuccessfully. The code below is just my first step to try to find the row, i know there are problems as i am unfamiliar with the different properties of a given variable.

Function FindRow(szName) As Integer

nFoundRow = 0
For nRow = 0 To Worksheets("Totals").Columns(nCol).Rows.Count
If StrComp(Worksheets("Totals").Cells(1, nRow), szName) = 0 Then
nFoundRow = nRow
End If
Next nRow
FindRow = nFoundRow
End Function

Sub Totals()

nCol = FindRow("Totals")
ActiveCell.Select = nCol
MsgBox (nCol.Value)

End Sub

View 9 Replies View Related

Find End Of Column And Bold Rows In Loop

Oct 17, 2007

I am trying to Find a cell containing a string ("derf" in this case). Then bold the entire row and continue to loop till it hits the end of the row and column.
Here is what I have.

Sub Macro3()
Range("B65536").End(xlUp).Select 'Finds the bottom in column B and sets it to endhere
ActiveCell.Value = "endhere"
Range("A1").Select 'goto the top
Do Until ActiveCell.Value = "endhere" 'The Do Loop Starts
Rows("1:30").Select
Set rfoundcell = Selection.Find(What:="derf", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
With rfoundcell
rfoundcell.EntireRow.Font.Bold = True
End With
Loop 'Keep looping till it hits the bottom of the columns row!
End Sub

View 2 Replies View Related

Find And Delete Rows In Vba

Mar 15, 2007

Basically i have a column which runs like this:

Company Name:

Name1
Name1
Name1
BLANK
BLANK
BLANK
Name1
BLANK
Name1

Basically, what I am after doing is getting a script to look through that column and delete any rows that do not have "Name1" in Column A.

So far, i've sorted the column so all the blank cells appear at the top, and the "Name1" cells appear at the bottom. Now what I was going to do was use a loop, and I got as far as this before becoming confused .....

View 3 Replies View Related

Find Value Then Delete All Rows Above

Jul 18, 2007

Looking for some VBA code that will look for the first instance of a certain value in Column A, (Begins with 9128),then delete all rows above that row. Then I need to look for a value in Column A that begins with 9129, and delete all rows below that. I've attached a sample workbook to illustrate.

View 3 Replies View Related

VBA Find Blank Row And Then Delete 15 Rows Down?

Sep 11, 2013

I need to loop through data when it finds a blank it need to delete that row and 15 rows down and loop through whole data set find blank row and delete 15 rows down.

It's been years since I did any VBA, and I forgot. Do I need to use offset to acheive this task?

View 6 Replies View Related

Find A Word And Delete All Rows Above It

Dec 18, 2013

I get a report each week that has a bunch of unwanted header info. It used to be static and the macro just deleted the first 49 rows. I recently found out that the header format changed and it's been deleting crucial data.

I need something that will find the words "Medical Center" and delete all the rows above it, however many that may be...

View 4 Replies View Related

Find Value In Column & Delete All Rows Below

Feb 23, 2009

I have searched high and low for a more efficient macro than the current loop i have. I have a range that varies in size but always follows the same format. After i reach a certain value output from a formula, "4", I want to delete all lines below that line. So I want to find value "4" then move one row down and delete all lines to line 2004. I have attached the macro that i compiled but it takes a couple of minutes to run.

Sub manual()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
. ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView.................

View 2 Replies View Related

Find Text & Delete All Rows Below

May 17, 2008

I have a report that comes in a txt file. After importing into excel i am left with a bunch of garbage that i dont need. This report is anywhere from 5-15 pages depending on how much product was made that shift. I only need the information off of the 1st page. My question is how can i Find the first occurance of specific text (Site) (will be in column A) and have it select that row and all rows below and delete them.
My biggest issue is the first page can be anywhere from 40-60 rows so I need to find the text (Site) and delete everything below it, which could be anywhere from 500-1500 rows.

View 2 Replies View Related

Find Value On Sheet & Delete Rows Below

Aug 6, 2008

I am trying to select all the data in every row below where the first "flat" entry in the worksheet is but it will only go to the bottom of the data in the column where it finds flat. Some data in other columns extends beyond this so it is not working for me. It would work for me to select everything from where it finds flat to the very last row 65536 but I can't figure out how to do that with what I have. I am then deleting all this data.

Cells.Find(What:="flat", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.EntireRow.Select
range(Selection, Selection.End(xlDown)).Select
range(Selection, Selection.End(xlDown)).Select
range(Selection, Selection.End(xlDown)).Select

View 3 Replies View Related

Find Particular Word And Delete Rows Macro

Aug 31, 2012

I am trying to get macro which will find word "Service" in sheet 1 and after that delete that row and below row.

View 1 Replies View Related

Find Macro To Delete Rows: 3 Questions

Jun 4, 2007

I have a worksheet that is several thousand rows long. It is sectioned into various "topics" (e.g. Revenue, Profit); each topic (there are about 100) has 10 companies. The 10 companies are the same for each topic. For instance, if 2 of the companies are Microsoft and Intel, then there will be a Microsoft row and an Intel row within each topic.

I am trying to write some code to delete every instance of a company (the user indicates the company in a form). So, for instance, if I want to delete Microsoft, the user would enter the stock ticker, MSFT, into the form and press the appropriate command button. When the command button is pressed, the code should find each row that contains the ticker MSFT (the tickers happen to be in column B) and delete it.

I have written the following unsuccessful
Private Sub CommandButton1_Click()

Dim Ticker As String
Ticker = TextBox1.Value

'If IsText(Ticker) Then

Range("$A$5").Select


Cells.Find(What:=Ticker, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate..........

View 9 Replies View Related







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