deleting full columns based on content of a cell

cresswell80

New Member
Joined
Oct 12, 2005
Messages
46
hi all,

i'm trying to write code that deletes a full column whenever a £ sign crops up in row 16... can anyone tell me what's wrong with the following:

Code:
Public Sub DELCOLS()



For intcount = 1 To 300

    

If InStr(1, Cells(16, intcount), "£") > 0 Then

    Columns(1, intcount).EntireColumn.Delete
        
End If


Next intcount

End Sub

thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Well, you are searching through 300 columns ( there are only 256 in Excel!!!! ), and you need to change
Columns(1, intcount).EntireColumn.Delete
to
Cells(1, intcount).EntireColumn.Delete
 
Upvote 0
Hi if i want to hide it and not delite it what is the code?

and if it is lines and not collums have do i change it?
 
Upvote 0
Hi clausboss, you'd be better of starting a new thread rather than tagging questions on to someone elses, but, here goes ... Hidden = True is the property to change for Row objects.
 
Upvote 0

Forum statistics

Threads
1,203,483
Messages
6,055,679
Members
444,807
Latest member
RustyExcel

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