Inserting multiple columns without a loop

FNeeq

New Member
Joined
Oct 2, 2014
Messages
15
I am trying to insert about 10 columns before a column with header "Analysis". Below is the code I am currently using. I will like to know if I can do this without a loop. Thanks

Code:
    Dim fnRange As Range

    Set fnRange = Worksheets(ActiveSheet.Name).Range(Range("A1"), Range("A1").End(xlToRight)).Find(what:="Analysis", _
    LookAt:=xlWhole, MatchCase:=False)
    
    With fnRange.Select
    
        For lngCount = 1 To 10
            Selection.EntireColumn.Insert
        Next lngCount
        
    End With
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
This should do the trick or so i think
Code:
Columns(fnRange.Column).Resize(, 10).Insert

so the code now looks like this
Code:
Dim fnRange As Range
Set fnRange = Worksheets(ActiveSheet.Name).Range(Range("A1"), Range("A1").End(xlToRight)).Find(what:="Analysis", _
    LookAt:=xlWhole, MatchCase:=False)
Columns(fnRange.Column).Resize(, 10).Insert
 
Upvote 0
So take it that it worked, right? :)

You are welcome
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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