Is there a way to tell Excel to do a macro thing for every second-next column?

Status
Not open for further replies.

okok

New Member
Joined
Mar 17, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi. I made a thread before but I'm not sure if it's clear what I want, as it's a bit difficult without showing you my data. So I thought this would be an easier way to ask, that might still help me achieve what I need.

So let's say for example that I have the following code in my macro, to make it add a couple of empty columns next to column F:

VBA Code:
Columns("F:F").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

Now say that I also want to do the same thing to the rest of my columns, for example to add a couple of empty columns next to column H.

To save me from needing to past the above code and manually change the column letter over and over, is there a code that automatically says "do this thing for every second column"?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Duplicate to: Please help me to fix my macro

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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