Home » excel » excel – Is there a smarter Way to address several Columns

excel – Is there a smarter Way to address several Columns

Posted by: admin May 14, 2020 Leave a comment

Questions:

I want to extract Data in a table. I use the TextToColumns feature.
I Know it is 4 entries long. I might have data to the right. (Depending on who is doing the data excerpt).
I want to insert the 4 Columns

I now have 4 lines of inserting a new column.

.Columns(searchCol + 1).Insert Shift:=xlToRight
.Columns(searchCol + 1).Insert Shift:=xlToRight
.Columns(searchCol + 1).Insert Shift:=xlToRight
.Columns(searchCol + 1).Insert Shift:=xlToRight

Is there a smarter more elegant way to do that?
(My code is running and working it is just about finesse)

How to&Answers:

To insert 4 columns at once left of column searchCol + 1:

.Columns(searchCol + 1).Resize(ColumnSize:=4).Insert Shift:=xlToRight