Entire Column to Delete

Gugan V

New Member
Joined
Mar 26, 2013
Messages
8
Hi,
From my worksheet, I have two sets of columns. Let’s say “REFNAME” and “DESIGNNOTE”
These two columns am generating from a XML file. My final column formats like (“REFNAME, REFNAME2, DESIGNNOTE, REFNAME4, REFNAME5, REFNAME10, REFNAME13, REFNAME19, REFNAME20, REFNAME25, DESIGNNOTE1, REFNAME26, REFNAME32, and REFNAME34”)
Here each “REFNAME” is a section in the XML file. For all section in XML file REFNAME is the mandatory column and not necessarily all section should have the “DESIGNNOTE” for above example, section REFNAME2 and REFNAME25 only contains “DESIGNNOTE”
Requirement:
My requirement is I want section only contains “DESIGNNOTE” so except the columns REFNAME2, DESIGNNOTE and REFNAME25, DESIGNNOTE1 I want to delete the remaining columns permanently.
Can any one have solution for this.

<i used this code.>
Sub DeleteEmptyRow(File)
Dim i, j As Long
Dim LR, LC As Long


Workbooks(File).Activate


LR = ActiveSheet.UsedRange.Columns.Count
For i = LR To 1 Step -1
If Cells(1, i) = "REFNAME" And Cells(1, i + 1) = "DESIGNNOTE" Then
Else
ActiveSheet.Columns(i).Delete
End If
Next
End Sub

But this code is not working properly :(
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
[I]LR = ActiveSheet.UsedRange.Columns.Count
For i = LR To 1 Step -1 [/I]

change to
Rich (BB code):
LR = activesheet.cells(1,columns.count).end(xltoleft).column
for i = 1 to LR
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top