Writing A Macro That Deletes Blank Rows

Dec 11, 2008

I need help writing a macro. I only have experience recording them, not writing them in VBA.

I need to check columns A and B for blanks. If A and B are both blank, I want the macro to delete the row and move on to check the next row. I need to perform this macro for the entire worksheet.

View 8 Replies


ADVERTISEMENT

Modify Macro That Deletes Rows

Aug 20, 2008

i have this macro made by another member here that looks for "T" in column 10 and deletes entire row if in that row has a "T". I need it modified to also delete if it contains "FT" and also erase if cells is blank.

Sub Macro8()
Sheets("FORMERS").Select
'deletes entire rows based on a text on one row (this case errases all that have a "T" in column 10 (column J)

Dim DeleteValue1 As String
Dim rng1 As Range
Dim calcmode1 As Long
With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With...........................................

View 9 Replies View Related

Speed Up Macro Code That Deletes Rows

Sep 13, 2006

I am trying to parse and remove unwanted rows from a very large text file using At the moment, the application runs rather slow and was wondering if the experts could give some pointers on how to make the code more efficient while still keeping it simple so others may be able to modify later. I am keeping the ScreenUpdating True as the alternative false will just show Excel as Not Responding to the user until the VB is finished.

Sub deleteReplaceRows()
Application.ScreenUpdating = True
Dim DeletedRows As Integer
Dim lastRow As Long
Dim Arr(7)
Arr(1) = "<PUZZLE>"
Arr(2) = "<%"
Arr(3) = "%>"
Arr(4) = "Response."
Arr(5) = "</PUZZLE>"
Arr(6) = "<HINT>"
Arr(7) = "<MESSAGE>"

For i = 1 To 7
Do
Set rng = Columns(1).Find(Arr(i))
If rng Is Nothing Then Exit Do
rng.EntireRow.Delete
DeletedRows = DeletedRows + 1...................

View 2 Replies View Related

Put Together A Macro For A Command Button That Deletes Rows With Certain Text In A Document

Feb 4, 2009

how to put together a macro for a command button that deletes rows with certain text in a docyment - which worked fine a week or so ago - but now the macro will not work.

I made changes to the document - but made sure i also made changes to the code.

View 2 Replies View Related

Writing A Macro To Hide Rows

Sep 23, 2008

I am now trying to hide rows when the data in a column matches that of a cell with a data validation list. Ideally i would like only the rows with matching data to show. When the cell is changed then the visible rows change and when the the entry "total" is selected all the rows are shown. There are several small tables of data on a page so I can't use auto filter. The data areas will also change in size as new entries are added. So the last row in the data tables will increase over time. I will copy and apply the macro to each separate table of data.

As an example cell c19 contains "lwsf"

The data table is in the range c24:q47. the column with matching data is column D so all rows of entries with "lwsf" in column D should be visible and the rest hidden. When c19 is changed to "TF" then the rows visible become those with TF in column D and the rest hidden.

View 14 Replies View Related

Writing Values To A Blank Cell

Aug 8, 2006

I have a combobox that the user selects a value from. Depending on what value is selected i want to write three different numbers to three different cells. I pretty much need to know how you get VBA to put a number in a cell. The numbers are nowhere on this sheet. Just in the code.

Case "1"
Sheet1.Range("M31").Activate
ActiveCell.Value = "1"
Sheet1.Range("O31").Activate
ActiveCell.Value = 0
Sheet1.Range("Q31").Activate
ActiveCell.Value = 0
Case "2"
Sheet1.Range("M31").Activate
ActiveCell.Value = 2
Sheet1.Range("O31").Activate
ActiveCell.Value = 0

View 8 Replies View Related

Macro That Deletes Certain Results

Jun 30, 2008

I am making a macro that deletes #N/A's, but i want to add a few things to it
that should be deleted:

the phrases "total board", "total metal" and "Item", and any non-text (i.e. any
number) that appears.

this is what i have so far:

View 9 Replies View Related

Macro That Deletes Row Before And After Certain Phrase

Nov 3, 2008

I need a macro that searches my spreadsheet for a keyword in Column B. If it finds the keywords (or an array of keywords would be even better), it then deletes the entire row above the keyword, the row with the keyword, and the row below the keyword.

So for example,

(Column B)
1 - Row Above
2 - Keyword Row
3 - Row Below

If the macro finds the text in column 2, it would delete 1, 2 and 3.

I need to have a second macro that performs a very similar function.
it copies the 3 rows (similar to the example below) to a different sheet based on the keyword.

View 3 Replies View Related

VBA Code Which Deletes A Macro

Aug 11, 2006

I’ve got a macro that automatically starts when the workbook is open. The macro finishes with

Application.Dialogs(xlDialogSaveAs).Show

The document will be always saved with a new name. As I just need the macro once when the workbook is created I’m looking for a code that deletes the macro before the workbook is saved. I tried to record a macro while I was deleting another macro, but apparently it is not working (the recorded macro is empty).
Does anyone know if there exists a code to delete a macro?

View 5 Replies View Related

Speed Up Macro: Deletes All Duplicates

Jun 6, 2007

It takes all numbers in column 4 starting with Row 15 and deletes all duplicates. It then shows the number of times the number was duplicated and puts this number in column 3. MY PROBLEM: The macro searches each line and takes FOREVER! I have data with thousands of lines. I already tried the screenupdating method which really doesn't help that much. Is there possibly a better code for doing this?

Sub Factor()
Dim sID As String
Dim sOldID As String
Dim lLastRow As Long
Dim lrow As Long
Dim lcount As Long
Dim lLoop As Long
lLastRow = ActiveSheet. Cells(Rows.Count, 1).End(xlUp).Row
lrow = 15
sID = ActiveSheet.Cells(lrow, 4).Value
sOldID = "ActiveSheet.Cells(4, 15).Value"
lcount = 1
lLoop = 1
Do While Len(sID) <> 0
If sID <> sOldID Then
If lLoop = 1 Then.................................

View 5 Replies View Related

Macro Stops Every Time It Deletes A Sheet

Oct 15, 2008

I have a macro that that stops every time I’m trying to delete the sheet. I get this message. “Data may exist in the sheet(s) selected for deletion. To permanently delete the data, prese Delete.” and I have to manually click “delete” to continue running the macro. How can I avoid this stop so that macro runs thru it without stops?

View 2 Replies View Related

Macro That Deletes All Cells In Column D Of All Worksheets

May 22, 2007

I need a Macro that deletes all cells in column D of all worksheets in a book that are equal to the word "Timeout" and to shift the cells to the right of the "Timeout" cells into the deleted cells but leaving all other rows where the word "Timeout" is not present.

So in the case of Rows 2, 4, 6 and 8 containg the word "Timeout" in column D, I would like cells D2, D4, D6 and D8 deleted and the remaining cells shifted to the left but cells D1, D3, D5 and D7 left as they are.

Here is an example line of data:

16:02:30LEXKRunningprocedure:125sth
16:32:30LEXKRunningTimeoutprocedure:X125sth
17:20:54LSXPRunningprocedure:oxford
17:56:48LSXPRunningprocedure:xoxford
18:48:24LEXKRunningprocedure:125sth
19:18:24LEXKRunningTimeoutprocedure:X125sth

View 9 Replies View Related

Prevent Formula #REF! When VBA Macro Deletes Columns

Aug 5, 2009

I'm using the following code to delete columns:

Dim rng As Range
Dim i As Integer, counter As Integer

Set rng = Range("1:1")

i = 1

For counter = 1 To rng.Columns.Count

'If cell i in the range contains an "x",
'delete the column
If rng.Cells(i) = "x" Then
rng.Cells(i).EntireColumn.Delete
Else
i = i + 1
End If

Next

My problem is that I have cells in other worksheets linked to the worksheet that is running this macro and everytime I run it, I get a handful of "#REF" errors. I think this problem might be solved if I could simply delete the contents of the column rather than deleting the entire column. How can I modify my code to do this?

View 4 Replies View Related

Macro To Split Rows Into Groups Of 5 And Insert 3 Blank Rows In Between

Feb 9, 2013

I would like to have my macro code search column A (supplier numbers) and split the rows into groups of rows of 5 or less and then insert 3 blank rows between each group of rows. The split needs to start on a new supplier number and cannot split a supplier number into two different groups. Here is a sample:

Supplier
Invoice Date
GL Date
Invoice Amt

[Code].....

View 1 Replies View Related

Macro To Separate Lots Of Rows With Certain Amount Of Blank Rows

Feb 15, 2014

I have been using this macro to separate lots of rows with a certain amount of blank rows.

Example:

Code:
Sub test()
Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")

[Code] .......

I trying to change it so that, instead of inserting how ever many blank rows, it just copys the row above.

Example (Row A to C)

I have been messing around with macro recorder and i could select each row and paste it into the blank rows, but from researching on the internet selecting and pasting data seems to be a waste of resources (ram?) and i will be running this on a couple hundred rows (lots of data). Also, i would like to keep the functionality so that i can still choose how many times it copys/inserts each individual row from a input box.

I eventually want the data to end up like it is shown in the table but i am takin it one step at time because i want to understand what the code is doing.

View 1 Replies View Related

Getting Rows To Columns Macro Skipping Blank Rows

Dec 28, 2011

I have this in Column A, with about 120 entries:

Company 1
Contact 1
Address 1
City, ST, ZIP 1
Phone 1
Fax 1

Company 2
Contact 2
Address 2
City, ST, ZIP 2
Phone 2
Fax 2

Company 3
Contact 3
Address 3
City, ST, ZIP 3
Phone 3
Fax 3

I want this:

Company 1 Address 1 City, ST, ZIP 1 Phone 1 Fax 1
Company 2 Address 2 City, ST, ZIP 2 Phone 2 Fax 2
Company 3 Address 3 City, ST, ZIP 3 Phone 3 Fax 3

all the way down.

I can't figure out how to record the macro to tell it to then skip the blank line, collect the next set of data, and put it in the next row. I can do it for two, but then it just replaces the first two with the next two and I lose data.

View 5 Replies View Related

Writing Macro To Check Cell Population And Then Run Another Macro

May 14, 2014

Basically, what I'm dealing with is an inventory system. When a cell value reaches below a certain quantity, we have a cell light up with the word "YES" (under the "re-order" column). What I'd like to do is have a macro that checks to see if that cell is populated with "YES" and if it is, to run another macro (which I already have written) that sends out an email notifying us of the need to re-order.

How it would work: The person pulling out the inventory would fill out this form and click "Submit"

submitbutton.jpg

I would then have a "call" code tied to the "Submit" button that when clicked, would run the macro to check cell population and send out the email. The email code is already written and works flawlessly on it's own. I just cant seem to figure out how to write a macro that checks for cell value and then runs it (or not) based on that.

View 14 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 Blank Rows

Dec 13, 2007

I need to write a macro that will successfully delete blank rows. I also need to write a macro that will successfully delete duplicates. The duplicates are numbers and they do constantly change.

View 9 Replies View Related

Macro For Deleting Blank Rows ...

Mar 3, 2008

I am able create a macro using the find function to find the next blank row, but I would like to have it select a range of rows down that I can then delete. Each time I run the macro the next blank row may be different thant the last, so it can't be a set number of row numbers each time. I could also possibly use the print area function if it would be easier.

Here is what I have so far, what is in red is where I need it to vary from next active blank row down to R2001C14, and then delete all the active blank rows ...

View 9 Replies View Related

Macro To Delete Blank Rows ...

Jun 12, 2008

I need a macro to delete blank rows from row 2, but excluding the last 4 rows where there is blank rows between the data

See example below where the rows containing blank cells after #2 in column A must not be deleted ...

View 9 Replies View Related

Writing Macro

Jul 3, 2007

i have an report in which i need to delete the entire row if the column contains values more than 250K, but the chanllenge here is; if any of the cells in the column contains a formula then the macro should not delete the row.....

View 9 Replies View Related

Consolidate Rows That Have Formulas In Them But Blank With Macro

Apr 3, 2014

I am looking for some VBA programming that will allow me to use 1 button to consolidate rows (delete them). The problem I am running into is that the rows I want to delete have formulas in them so I can use "find all blank cells & delete" type of macro.

Capture.PNGCapture1.PNG

Attached are a couple of brief images on a small scale what I am looking to do.

I want a user to be able to have this sporadic list of choices, consolidate them so the are all one right after each other, then export to a word file for editing later on.

View 1 Replies View Related

Macro To Delete Any Blank Rows In A Worksheet

Mar 8, 2009

I've added a button with a macro to delete any blank rows in a worksheet.

Cell A3 is completely blank and A6 has an IF formula which returns "". In my macro it copies the whole worksheet and then paste special values, to take away the formula in A6 and then deletes the blank rows but it still does not delete row 6.

View 4 Replies View Related

Macro To Delete Blank Rows With Formula

Jul 30, 2009

I'm trying to find a way to delete blank rows that contains formula. I have two excel sheets.
sheet1 contains information and sheet2 references the values from sheet1. Let's say I put the following values in sheet1:

ColA
AAA
(blank)
(blank)
BBB
(blank)
CCC

After entering above values in sheet1, here's what sheet2 would look like:

ColA
AAA
(blank that holds formula) =IF(ISBLANK(Sheet1!A2)," ",Sheet1!A2)
(blank that holds formula) =IF(ISBLANK(Sheet1!A3)," ",Sheet1!A3)
BBB
(blank that holds formula) =IF(ISBLANK(Sheet1!A5)," ",Sheet1!A5)
CCC

What I really wanted to happen is for macro to eliminate blank rows in sheet2 to look something like:
ColA
AAA
BBB
CCC

Is it something possible?

View 14 Replies View Related

Macro To Delete Blank Rows In A Table

Sep 14, 2012

I recently found this macro on these forums for deleting rows where all of the cells are empty.

Code:
Sub RemoveEmptyRows()
On Error Resume Next
With Range("B300:B1000")

[Code]....

View 9 Replies View Related

Macro To Delete Rows Where There Are Blank Cells

Sep 25, 2013

I would like code that will delete all rows where there are blank cells in Col D from row2 onwards.

View 2 Replies View Related

Macro To Copy / Paste On Blank Rows

Apr 28, 2014

What I have are dates in Column B with a lot of blank rows in between. For example: cell B2 has a date in it and then the next date would be on cell B54. I need a macro to copy cell B2 until it finds a new date (which is in cell B54) then copy the date in cell B54 until the next date again.. so on..

View 9 Replies View Related

Loop Through Rows Until Blank And Call Macro

Feb 16, 2007

I have a spreadsheet with a list of names from cell A5 to A? - can be as many as 130 names or as few as 20. I have to create individual spreadsheets with the persons name as part of the filename. I have 3 subroutines which work manually ( CreateFile, LookUp and NewWorkbookSave ) so that I can generate individual files for those users who require them. However I need to be able on occasions to create a full teams worth of files with one click - to this end I need to be able to loop through cells A5 - A whatever and call the Subroutine CreateFile - I enclose the code I have so far

Const Fname = "AON Ver 3,0.xls" 'insert filename here like "AON Ver 3,0.xls"
Const DirName = "\Ukplscs105central repositoryAOMTally SheetsTeam upload Tally sheets"
Const TeamName = "AON" ' insert team Name here like "AON"
Const FilePath = DirName & TeamName
Dim count As Integer

Sub CreateFile()
ChDir FilePath
Workbooks.Open Filename:=FilePath & Fname
Range("C3").Select
ActiveWindow.WindowState = xlMinimized
Call LookUp....................

View 5 Replies View Related

Writing VBA Macro Or Function

Nov 5, 2007

I have Asset Class in Column I and if it is 364A-EL or 365A-EL or 368A-EL or 368B-EL or 369A-EL or 371A-EL or 371B-EL or 373A-EL or 397C-EL then 'POLES' assigned in to Owner Class (Column J).

If Asset Class is 366A-EL or 367A-EL or 367B-EL or 368C-EL or 369B-EL or 371C-EL or 373B-EL then assign UGCBL to Owner Class.

Should we write the macro or can it be accomplished by any Excel Function?

View 11 Replies View Related







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