Automating a task

JeanieW

New Member
Joined
Apr 13, 2011
Messages
4
Hi
It's my first posting here and apologies if the answer to this question has already been posted. I'm not really familiar with Excel so not sure what I'm looking for. Anyway, here goes:

I am downloading files to Excel and have been deleting unwanted columns manually. However it would be more than a little useful if someone could tell me how to automate the removal of multiple columns (not necessarily next to each other, but the same ones each time) in one go.

Many thanks in advance
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi
Thank you for your reply. Please bear with me as I am not good with Excel. When my data has been imported into Excel, it always comes across with the same column format. Some columns have no information and I want to be able to set up a macro that will take the preselected columns B. E, I, K, L, Q, S, T, U, V, X Y & Z + AA - AK and delete without me having to manually select each column and delete every day.
I guess I need to know that this can be done, and if so, how I do it as I've two different imports where I will need to delete columns not required and they are not the same.
Hope this makes sense:confused:
 
Upvote 0
Sample:

Code:
Sub Foo()
ActiveSheet.Range("B1,E1,I1,K1:L1,Q1,S1:V1").EntireColumn.Delete
End Sub
 
Upvote 0
Sample:

Code:
Sub Foo()
ActiveSheet.Range("B1,E1,I1,K1:L1,Q1,S1:V1").EntireColumn.Delete
End Sub

Many thanks for this - now what do I do with it? As I haven't a clue what to do, as much detail as you can give would be much appreciated. Please assume I know nothing - you wouldn't be far wrong.
 
Upvote 0
You need to copy the 3 lines (of code) into the Visual Basic Envirnment (VBE);
Steps
1) Highlight and COPY the 3 lines of code;
2) While in you spreadsheet - at the keyboard press the Alt + F11 keys combination
this is open the VBE -- At the Menu look for Insert, then Module - a large open window shoud suddenly appear on the right-hand side. Click inside this window and then Paste (or Ctl+V). This should drop the 3 lines of code into this window. At this point be sure to SAVE the file (Disc Icon). Close the VBE (X in top right corner);

Run the Macro Foo (or you can rename it whatever you want)..

Good Luck,

Jim
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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