How To Delete Entire Columns

Aug 19, 2013

I'm having some problem with a part of my code that deletes entire columns. With ActiveCell as my reference, I want to delete 'Abs_Diff' Columns to the left hand side of the ActiveCell column, including the ActiveCell column. 'Abs_Diff' is a variable of integer type.

SO if ActiveCell column is "P" and 'Abs_Diff'=2, then delete Columns "O:P"
if ActiveCell column is "P" and 'Abs_Diff'=4, then delete Columns "M:P"

My code is selecting columns incorrectly, maybe due to merged cells in cols A,B,C or something..not sure.

Here is my code:

Code:

'DELETE COLUMNS
Set StartPoint = ActiveCell
For X = 1 To Abs_Diff
StartPoint.EntireColumn.Delete
Set StartPoint = ActiveCell.Offset(0, -1)
Next X

View 1 Replies


ADVERTISEMENT

Delete Entire Row If It Has Unique Value In Two Columns?

Aug 22, 2013

I have worksheet, whose snapshot is given under (in reality, there are over 2000+ rows in worksheets)

I want a Macro which can perform following function in entire worksheet used range

Only retain the rows where the cell value in current row is identical BOTH in Column B, as well as column D in its immediate previous row

i.e. B14=B13 and ALSO D14=D13 (both condition should be valid, if not Delete entire ROW, i.e. having unique value)

Normally, ppl wish to delete the duplicates, but i want to retain the duplicate as identical data is of two different dates, control in Column O

My Worksheet looks like - [URL]

View 8 Replies View Related

Search And Delete Entire Columns

Sep 27, 2007

I have Column Headers in Row 1 (except column A), What I need to do is write a Macro or some code to

1.Search the entire row 1 for column headers containing the suffix _CSV and delete the entire columns.
2.Shift all remaining columns to the left so no blank columns exist. (There is a time stamp in row A that I wish to keep where it is.)


Next I would like a separate routine to sort the columns in the order of a Pre-defined list that I specify in a range. For example the list of column headers reside in the Range (A1:A200)

View 9 Replies View Related

Delete Entire Rows With Duplicates In Two Columns Only

Apr 20, 2012

I need excel to delete entire rows if there are duplicates in two columns combined.

So, if I have this sample data (in reality I have a lot more columns)

1 Tr. ID Last Name First Name Sex
2 RBM_A Miller Johnny M
3 RBM_A Bayron Josephine F
4 RBM_A Jackson Reynaldo M

[Code] ........

I want excel to delete only row 9, not 11, 13 or 14.

So far, if I look for duplicates in both columns it marks duplicates in either one. Also if I delete the duplicates, it deletes them only in those two columns, leaving me with distorted data (in this example, row 14 would have no last or first name, but only the values "RBM_C" in column B and "F" in column E.

View 2 Replies View Related

Delete Entire Row If

Oct 28, 2008

How would i search the entier worksheet im in, looking at column b only, and delete the entire row if i find the word Date in it.

View 9 Replies View Related

Delete Entire Row

Sep 24, 2006

when i delete the entirerow, it shifts the rows up (which is what I want) but it skips that row when it does.

so if I have 2 blank cells together it will delete the 1st and leave the 2nd blank.

Sub ()
Dim myrange As Range
Set myrange = ("a:a")
For Each c In myrange
If c.Value = "" Or c.Value <= 5 Then
c.EntireRow.Delete
End If
Next

End Sub

View 5 Replies View Related

Delete An Entire Row If Condition Is Not Met

May 3, 2006

I'm working on Outlook 2003 and Word 2000 which are not compatible. I have an
Excel Sheet which are my contacts from Outlook and I want to re-work it to
have only a certain category left.

I need a macro that does
- search a certain column
- deletes the row if it does NOT find a certain condition

Ideal would be a little pop up window to enter which category I want left.

View 9 Replies View Related

Delete Entire Row If Value Match?

Dec 11, 2012

I written one code to delete Entirerow if value match. It's working fine .the code delete all match except one match.!

-------------------------------------------------
Option Compare Text
Sub delete_duplicate()
Cells(Rows.Count, 1).End(xlUp).Select
Range(ActiveCell, Range("A1")).Select
For Each cell In Selection
If cell.Value = "Already updated" Then
cell.EntireRow.Delete
End If
Next
End Sub
-----------------------------------

View 3 Replies View Related

Macro - How To Delete Entire Row

Mar 17, 2014

If column B contains the word FALSE, I need to delete that entire row, then I need to repeat this action on 11 sheets out of 14 on one workbook, in one action.

View 6 Replies View Related

Delete The Entire Row That Has The Text Pc.

Sep 18, 2008

I use the code below to delete the entire row that has the Text "Pc." in it. How can I make this delete the row with "Pc." plus the next row?

Sub PL()
Dim i As Long

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
If InStr(Cells(i, "A").Text, "Pc.") Then
Cells(i, "A").EntireRow.Delete
End If
Next i

End Sub

View 9 Replies View Related

VBA- Delete Entire Row Which Has The Highlighted ...

Feb 17, 2010

i have over around 1500 pfolios in Col A, i need macro that will delete entire row which has the highlighted pfolios. Now i tried advanced filter which would work but the date in Col A6 will change every month, so dont want to go down that road, is there alternative option other than advanced filter ..

View 9 Replies View Related

Lookup Value, If Not There, Delete Entire Row

Apr 26, 2007

I am trying to Lookup multiple values (can't be done manually) in one report (Report 2) from another (Report 1).

If the value from Report 1 isn't present in Report 2, I want the entire row the value is found in (From Report 1) deleted.

View 4 Replies View Related

Delete Entire Row Of An Array

Jun 29, 2007

I want to know if there is a way to delete an entire row from an array? I have a 2 dimensional array and I want to loop through the elements in the first column and delete an entire row based on some conditions. Since the number of rows are too many usual looping takes a long time so I want to use an array.

View 9 Replies View Related

Find Value & Delete Entire Row

Aug 28, 2007

I've a worksheet containing a list of items some of which need deleting. These are identified from a particular range where users input "y" to notifiy the record can be removed. The code below works just fine if all I do is Clear the cells containing "y". However using: Range(rCell.Address).EntireRow.Delete

the macro stops after deleting the first item. It suddenly believes there aren't any further items to delete and Ends. There are no error messages returned. Entire macros is below.

Sub unreg_report()
Dim rRange As Range, rCell As Range
Set rRange = Range("unreg_list").SpecialCells _
(xlCellTypeConstants, xlTextValues)
For Each rCell In rRange
If rCell = "y" Then
Range(rCell.Address).EntireRow.Delete

End If
Next rCell
End Sub

View 2 Replies View Related

For Loop And Delete Entire Column

Oct 1, 2012

I have two worksheet. One worksheet (ws1) contains a list of item I want. The other sheet (ws2) contains multiple columns where the header (row 6) is named by item name.

I have the following code which deletes the entire column if the header name is not in the list contained in ws1 :

VB:
Sub delete_col()
Dim wanted As Boolean
Set ws1 = Workbooks("test1").Sheets("aaa")

[Code]....

First of all, this loop does not work properly since deleting the entire column shift them on the left, so when I first analyze column 11, if I delete it and then analyze column 12, the real column 12 now became column 11 and so on...

Secondly, this code is pretty slow. I am pretty sure I don't have to loop through my initial item list everytime I do Instr on a new column.

View 9 Replies View Related

How To Delete Entire Column If It Is Empty

Feb 21, 2013

I have columns

Row 1 is heading..

IF Column C doesn't have data in entire column then delete C D E F
IF Column D doesn't have data in entire column then delete D E F
IF Column E doesn't have data in entire column then delete E F
IF Column F doesn't have data in entire column then delete F

Same way for heading NN's

IF Column G doesn't have data in entire column then delete G H I J K L M N
IF Column H doesn't have data in entire column then delete H I J K L M N
IF Column I doesn't have data in entire column then delete I J K L M N
IF Column J doesn't have data in entire column then delete J K L M N
IF Column K doesn't have data in entire column then delete K L M N
IF Column L doesn't have data in entire column then delete L M N
IF Column M doesn't have data in entire column then delete M N
IF Column N doesn't have data in entire column then delete N

View 1 Replies View Related

Delete Entire Row If Column D Has A Numeric Value?

Apr 15, 2014

i want to delete entire row if D2:D10000 has a numeric value e.g .111 to 100000.1114

View 4 Replies View Related

Delete Entire Row If Column C Is Blank?

Apr 16, 2014

i want to delete entire row if Column C2:C1000 are blank

e.g if range c2:c100 have data then delete the rows C101:C1000

View 3 Replies View Related

Delete Entire Column If Row Has Certain String?

May 5, 2014

I have fixed headers on row 16, from columns A-AC.

I want to be able to delete the entire column, if the row has a certain string, such as "Chart ID" .

I also want to expand it to include other strings such as "Month" and "Source" . So if it contains any of these words, the columns should be deleted. It should be an exact match (as other headers contain the word "month").

View 12 Replies View Related

VBA To Delete Entire Row Based On Condition Met?

Jun 16, 2014

I have table in which against the Column A data values are added in Column B, C and D.

If Column B,C and D cell values is 0, then I want entire row including A to be deleted. How can I do this in VBA?

Note: Column A data begins from Row 15 and below.

Just to avoid confusion. I want row deletion, only when all the three cell on B,C and D is = 0

View 7 Replies View Related

How To Delete ENTIRE Row If Only One Cell Is Duplicated

Jun 15, 2011

I have a file with 238 rows and 10 columns (see file attached) Column G include phone numbers, some phone numbers are duplicated.

How can I use a macro (I must do it with a macro) to delete the ENTIRE row if the value in column G is the same in other row?

For example: look at rows 2 and 3 : the value in column G2 and G3 is the same, therefor delete row 3

(and if the value in G4 was also the same, then delete also row 4, and so on..)

View 10 Replies View Related

Delete Entire Row Based On A Condition

May 13, 2009

I have a problem deleting rows based on a condition, i didn't know how to use offset method.

i'm using a table like this one :

A B C
1 Main design1 FFR0
2 Extra design2 FFR0
3 Main design3 FFR0
4 Extra design4 FFR0
.
.
n Main designn FFR0


I want to delete entire row if "FFR0" in column C exists in a row beginning by "EXTRA" (column A)

View 6 Replies View Related

Delete Entire Row Based On Selection

May 27, 2009

I have a worksheet where I have restricted the users from scrolling around beyond a certain range.

Because of that the user is prevented from selecting an entire row.
There are some cases where the user should be able to delete entire row or range of rows.

How can I allow them to select say cells "C17:C35" [they would just hoghlight the range] and hit ctrl+d; which would trigger a macro and the macro in turn would delete all the rows in that selection [rows 17 through 35]?

I know some basic codes for deleting entire rows, but I don't know how to read first and last row of the selection under Target property.

View 3 Replies View Related

Delete Entire Row If Specified Word Exist

Dec 12, 2009

In range A1:A300 I have a lotof words. What I want is to delete entire row if the cell value is Open date

View 3 Replies View Related

Delete Entire Row Of Result Of Autofiltering?

Mar 2, 2012

I need to delete entire row of the result of autofiltering i.e. the visible rows only

If I do this manualy it works but if I record this on a macro, it records the absolute cells range I pick, when in fact the result of the filtering is different every time.

Is there a way around this with VBA?

I've Seen Copy paste in this forum but in my case i need to delete the entire row.

View 1 Replies View Related

Delete Entire Row Based On Specific Value?

Jul 18, 2012

Ihave a list of names in column A in certain rows instead of name there is an email address in this case I want to delete the entire row

View 4 Replies View Related

Delete Entire Row If Cell Contains 3 Characters

Sep 5, 2013

I can't get this code to work which I want to delete the entire row if the cell in the specified range contains only 3 characters;

Code:

Sub CharCount()
Dim cell As Range
Dim bottomK As Integer
bottomK = Range("D" & Rows.Count).End(xlUp).Row
Dim rng As Range
Set rng = Range("D2:D" & bottomK)
For Each cell In rng
If Len(cell) = 3 Then
EntireRow(bottomK).Delete
End If
Next cell
End Sub

View 6 Replies View Related

How To Delete Entire Row That Has Blank Cell

May 14, 2014

VBA codes in filtering blanks.

Here is a screenshot, and what i want to do is to delete the entire row that has a blank cell. In which here, the 5th row, 7th row and 9th row.

View 5 Replies View Related

If Column B Is Blank Delete Entire Row

Jul 23, 2007

I am using the following macro to delete "completely empty" rows. I also need to delete some rows if a cell in column B has no value. How would I change this macro?
' DeleteBlankRows

Dim r As Long
Dim C As Range
Dim Rng As Range

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
For r = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(r).EntireRow) = 0 Then
ActiveSheet.Rows(r).EntireRow.Delete
End If
Next r

EndMacro:

View 9 Replies View Related

If Cell Contains The Word Delete Entire Row

Dec 10, 2008

Looking to write a macro to delete an entire row if the word GROWTH is found in any cell under Column C.

View 9 Replies View Related







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