Deleting An Entire Column

May 2, 2006

Need the code for deleting multiple columns simultaneously in an excel depending on some search criteria.Suppose I want to delete the columns whose names are "Roll No" ,"Age" & "Class"

View 2 Replies


ADVERTISEMENT

Deleting Entire Column - Statement Ignored

Apr 11, 2012

Working on some code that will find the Column Name "CL" and delete the entire column. Here is what I have so far...it does not give me a error when it compiles, but for some reason the statement in red is being ignored. I tried switching Range with Columns, but that did not work.

Private sub coldelete ()
Dim Rng2 as Range

shUCLR = sheets("Unit Cost").usedrange.rows.count
Set Rng2 = Sheets("Unit Cost").Range("A1:BF1")

For Each d In Rng2
If d = "CL" Then
colnum = d.Column
colletter = Left(Sheets("Unit Cost").Cells(1, colnum).Address(False, False), (colnum)

View 2 Replies View Related

Deleting The Entire Row In VBA

Dec 24, 2007

I have a spreadsheet with thounsands of rows. Some of the rows I'd like to delete because thier values are below 5%. I wrote a VBA code, which primary function is to look for a cell and delete the row if the value is less than or equal to 5%. The code looks fine but I get an "Infinite Loop" anytime the first row value is not true. Below is the code,

-jungleman1

Sub Delete_Zero_Factors()

Dim i As Integer
Dim CUSIP As String

Sheets("Report").Select

Range("B5").Select
i = 0

While Not (IsEmpty(ActiveCell.Offset(i, 0).Value))
CUSIP = ActiveCell.Offset(i, 0).Value

Do While (ActiveCell.Offset(i, 1).Value

View 9 Replies View Related

Deleting Entire Row That Has Cells With Certain Strings?

Mar 16, 2013

I am trying to delete entire row that has certain text, let say "hi". I was able to delete cells with exact word "hi", but was not able to delete cells that have texts other than "hi". ex) "hi myname." Below is my vba code, and I keep getting run-time error and cannot execute the code.

VB:
Sub HiDelete()
Dim srchRng As Range
Set srchRng = ActiveSheet.Range("g:g")
For i = srchRng.Rows.Count To 1 Step -1
If worksheefunction.Search("hi", Cells(i, 7)) > 0 Then Rows(i).Delete
Next i
End Sub

View 3 Replies View Related

Deleting Entire Rows Containing A Specific Value

Aug 29, 2007

I've been tasked with developing a macro that will generate schedules. For background, we're taking a QuickBooks Customer file and exporting it to be picked up by the macro. I've got that part working, but now I need to delete various rows based on certain criteria.

The spreadsheet has a field for Job Status which we use to define whether an account is under contract (2 in QuickBooks), or some other status. Basically what I need to do is delete the entire row of data where JobStatus (Column R) is anything but 2.

View 9 Replies View Related

VBA Deleting Entire Row When Certain Word Appears?

Dec 12, 2012

I currently have the following code that works great and deletes the row from my spreadsheet when the word "vacant" appears in column F.

Sub test()
Dim r As Range
With ActiveSheet[code]....

The problem is, "Vacant" also sometimes appears in column G. So, as this code is now it is finding the word "Vacant" in either column F or column G and then deleting the row.

How can I write the code so that it only deletes the row where "Vacant" appears in column F but ignores it when it is in column G?

View 3 Replies View Related

Macro Is Deleting My Entire Sheet

Nov 15, 2006

Sub Delete()
Dim x As Long
For x = 28 To 8 Step -1
If Range("b" & x) = "" Then _
Range("b" & x).EntireRow.Delete
Next x
End Sub

View 9 Replies View Related

Deleting Entire Rows Once Filter Has Been Applied

Nov 24, 2011

I've got a report which is approx 40,000 rows long and I need to delete out alot of the info.

I need to delete out entire rows if column C contains a 0.

I've written a loop to do this but as theres so much data it take a long time to run.

Is there a smarter way to do this?

View 6 Replies View Related

Deleting Duplicate Cells (not Entire Rows)

Dec 17, 2007

I have a long list (over 1000 lines) of numbers, some of which are duplicated. Up to now I have been sorting them, adding in a simple check column to see if the number is a duplicate of the one below, and then manually deleting this cell.

Is there a better way to do this using VBA? The only way I have managed to find is by deleting the entire row, but I cannot do this as I have additional data to the right that I need to keep.

I also cannot install any add-ons as this on a work computer.

View 9 Replies View Related

Deleting Entire Customer Entry If One Cell Is Blank?

Dec 24, 2008

I have a large database of customers. I would like to edit this database so that it only lists those customers that have an email address listed in that particular column. I can then save that as a separate list to upload to my marketing campaign.

Is there an easier way than just deleting entire rows at a time? About a 2,000 name list with maybe 30% having email addresses.

View 2 Replies View Related

Deleting Entire Columns Based On Cell Formatting

May 15, 2009

I'm trying to come up with a macro that can delete an entire column based on formatting of the cells. Basically what I have is a range of cells, and if all cells in a particular column have no fill color, then delete the entire column.

View 9 Replies View Related

Moving And Deleting Entire Rows Between Tabs In Workbook And Moving Them Back If Needed

Sep 23, 2013

I have an excel work book with 6 tabs. I would like to have Excel move an entire row from one tab to another tab (removing the row and inserting it in the other tab). I.e. Example I have a tab with items that are marked as "Open Actions" so if I were to change the drop down to close. Excel would move that entire row of actions to the tab with the "closed actions" and insert into the next available row. Now if someone were to come back at a later date say no it should be reopened than I would change the drop down to open and excel would move that row back to the open actions tab into next available row. I tried a PIVOT table and no good I played with few macro and not.

View 5 Replies View Related

Macro Optimization And Moving Text From One Column To Another And Deleting Previous Column

Nov 7, 2009

I am running Win XP and Excel 2003.

I have a macro I found here on the boards written by Lenze to delete an entire row based on what is found in column A. I would like to delete any row where Col. B contains 10 or less characters and I have modified it to do so (or at least I think it does). My problem is that it takes about 12 minutes to run the macro (I have about 50k lines to run through). I was wondering if this is the fastest method or if it examines things other than just column B.

Sub Test()
Dim i As Long
LR = Cells(Rows.Count, "B").End(xlUp).Row
For i = LR To 2 Step -1
If Len(Cells(i, "B")) < 11 Then Cells(i, "B").EntireRow.Delete
Next i
End Sub
After this runs, I am left with Columns A to somewhere around AH. The columns are generally in the format of text followed by a numeric column. An individual text column has the same name through all of the rows. The numeric columns have varied values whether negative or positive.
Ideally what I would like: If a given cell (ie. C2) in Row 2 is numeric, then copy the cell to the left (ie. B2) into (ie. C1) and then delete Column B. I need this to work for multiple columns from B to C, skip D and E, and then from F to AG (and maybe beyond).

View 9 Replies View Related

Delete Entire Row If Column A Matches Column D

Aug 18, 2009

Does anyone have a macro that will delete entire row if column a matches column d

View 6 Replies View Related

Content From Entire Column In Other Column

Feb 10, 2012

I need to do the following:

I have a list of cities on one sheet. The headers are the counties and below each (6 columns) are all the cities names.

I need to be able to show all the cities of a specific column on a nother sheet (autofilling column down with all cities names) when i type the name of the related county in an adjacent cell.

View 2 Replies View Related

Tie IF Statement To Entire Column

Jul 17, 2013

The subject summarizes what I want to achieve. I just want to tie an if statement to an entire column, so it will disappear if a statement is satisfied.

View 4 Replies View Related

Keep Formula Same For Entire Column?

Apr 5, 2013

I'm inserting new information at the top of my worksheet. Unfortunately the formula for what WAS row one: =SUMIF(TotalSales!$B:$B,A1,TotalSales!$H:$H) Will no longer work for row one because as more date is collected row 1 shifts down to row 2. Row two still looks good but there is no longer a formula for the new rows inserted.

To be clearer... I would like to have the following:
=SUMIF(TotalSales!$B:$B,A1,TotalSales!$H:$H) in cell B1
=SUMIF(TotalSales!$B:$B,A2,TotalSales!$H:$H) in cell B2
=SUMIF(TotalSales!$B:$B,A3,TotalSales!$H:$H) in cell B3

How can I keep that formula in row one as I keep inserting new rows?

View 2 Replies View Related

Macro For Entire Column

Nov 12, 2013

I have created one excel which contains column with range. (A1:A6). and the drop box included the values as Passed, failed, NA, NC) i have coded the the macro to change color as if i select passed from A1 then A1: F1 will be Red. please find the below code.

Sub Prasanna1()
Range("A1").Select
Select Case Range("A1").Value
Case "Prasanna"
Range("A1:F1").Interior.ColorIndex = 7
Case "Kale"
Range("A1:F1").Interior.ColorIndex = 0

[Code]...

The code is working fine for one row. Now i want to set the same code for entire column A. as if i will select A10 the same range of row should get change with fill color.

View 3 Replies View Related

Look At Entire Column For Two Key Words

Apr 9, 2009

I have a work book with a lot of information. In column “W” I have a text comments, cells in this column probably have something or not, and the text is very variable. What I need is an instruction to look at entire column for two key words for example: "na co", "apna" or "apcredit" ... in case of one of these words its found I need the macro to make a process.

For example if in the column W there is any item (cells) with text "apnapo" then

First filter the information:

Selection.AutoFilter Field:=23, Criteria1:="=*apna*", Operator:=xlAnd
Range("K1").Select
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select
Loop

Then write down something in columns K & L

ActiveCell.FormulaR1C1 = "Ion Apnapo"
ActiveCell.Offset(0, 1).FormulaR1C1 = "Pamela Elizondo"
Selection.Offset(0, -1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(0, 1).Select
Selection.FillDown..................................

View 9 Replies View Related

Select Entire Row &amp; Column

Feb 19, 2010

As the title sugests I would like to Select a cell and a macro will highlight the row and column

Sub Select_Entire_Row()
Dim RowNo As Integer
Dim ColNo As Integer
RowNo = Selection.Row
ColNo = Selection.Column
If RowNo.Value >= 1 Then
Cells(RowNo, ColNo).EntireRow.Select ' I want it to do both not one then the other
Cells(RowNo, ColNo).EntireColumn.Select
End If

End Sub

View 9 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

Drop Down Lists For Entire Column?

Jun 26, 2009

i know how to make a drop down list and then I can strech it over X rows but how do I set somthing like from C3 and forever onwards (C4,C5,C6..)use this droplist. I do not know how many entrys will be made so from C3 and onwards I need all cells to have this drop down menu.

View 2 Replies View Related

Append Text To Entire Column

Jan 16, 2010

I have a list of number in a column that there is over 22,000 is there a away I can add ".jpg" ad the end of each number?

View 10 Replies View Related

Display Entire Column In One Cell?

Dec 17, 2012

I want A1:A400 to display in B1.

View 6 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

Macro To Cut And Paste Entire Column?

Jun 2, 2014

I recored a macro to Cut the entire "E" column and paste on "A". For some reason when i read the code it doesnt capture the part where it needs to paste it in column "A".

View 1 Replies View Related

Edit VBA To Transfer Entire Row Instead Of Only Column A

Mar 3, 2014

Im trying to compare sheet 1 Column A, with sheet 2 Column A, and then move any duplicates (along with the row of data) from sheet 2 over to sheet 3.

For instance, Employee Numbers that match in both sheet 1 and 2, remove that entire row from sheet 2 to and insert it into sheet 3.

VBA that compares sheets and moves duplicates found in column A to sheet 3 but it leaves the rest of the row on sheet 2.

[Code] ......

View 10 Replies View Related







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