Deleting Columns Via Macro

trainer75

New Member
Joined
Jun 11, 2015
Messages
33
Hi,
Hope someone can assist me, i have am new to the whole macro/formula experience and have spent 5 hours today trying different methods of trying to do this.

I have to run reports every week and need to streamline how long it take me to do, so i want to delete out columns in excel that i do not need, only thing is week by week the number of columns changes so cannot use a fixed formula/macro, so started looking at deleting via certain text in one of the cells, which i done by the following:-
Ctrl F chose find and entered the data, then Find All, Selected Ctrl A to highlight all values with the data required, closed down dialog box and then right click delete entire column, job done :-) but when i done this in a macro it deleted the whole sheet.

Hope someone can help me,
Thank you in advance
 
You could guard against trailing spaces by changing the Select Case line to:

Code:
Select Case Trim(Cells(1, i).Value)
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
WOW, yes it does :-)
so if i add the extra space at the end of the word that should pick it up?
Im learning every day, hope to get a greater knowledge of the product like yourself one day,
You are a superstar, works brilliantly, thank you most sincerly for your help :-)
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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