Deleting column based off special character

aka_krakur

Active Member
Joined
Jan 31, 2006
Messages
438
I have a spreadsheet that is brought in by a comma delimin drill down (an online Intranet tool at my work).
This is pretty much how it looks (minus the bolded columns; I made them bold to emphasize the columns I want to delete)
I want a simple button driven macro that automatically deletes columns based off of if Row 3 does not contain a "/" I've done it before on rows, but I looked at the code and couldn't figure out how to tweak with it for use with columns.

here's my example:

[HTML removed by admin]
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

perhaps this ?
Code:
Sub test()

Dim LC As Integer
Dim i As Integer

LC = Cells(3, Columns.Count).End(xlToLeft).Column

Application.ScreenUpdating = False

    For i = LC To 1 Step -1
    If InStr(1, Cells(3, i), "/") = 0 Then Cells(3, i).EntireColumn.Delete
    Next i

Application.ScreenUpdating = True

End Sub
kind regards,
Erik
 

aka_krakur

Active Member
Joined
Jan 31, 2006
Messages
438
Worked except somehow it even deleted Column 1 (which contains the part nos.) Need to keep that.
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Worked except somehow it even deleted Column 1 (which contains the part nos.) Need to keep that.
step through code using key F8 & see what happens
you'll find where to edit
possibly without internet-connection within 2 hours till 22th sept
 

Forum statistics

Threads
1,136,369
Messages
5,675,362
Members
419,565
Latest member
Phil57

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
Top