Welcome to Chandoo.org Forums. Short message for you

Hi Guest,

Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide.
When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing
Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

Yours,
Chandoo

Hi All

Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

Post Spam and you Will Be Deleted as a User

Hui...

When starting a new post, to receive a quicker and more targeted answer,
Please include a sample file in the initial post.

I found through web, Magical 1 liner code , for work on multiple contiguous or Non contiguous columns. (multiple single columns or multiple range of columns, you can use both different aspects, through cover both in one line , in one shot)

Though , it not seems 1 liner at any angle, but,
after study ,practice & understand, Please remove not required part from code so its really transform in little.

Hope users who in search for code to process on multiple columns ,
below code will be very helpful them,

Code (vb):

OptionExplicit

'AMAZING ONE LINER CODE FOR DELETE /SELECT/PROCESS MULTIPLE COLUMNS( CONTIGUOUS OR NON CONTIGUOUS) IN ONE SHOT'BELOW SIMPLE EXAMPLE IS FOR PROCESS ON COLUMNS , AS DECLARE IT AS A RANGE OBJECT

I don't think the error comes from « entire column »
when watching your error screenshot,
more guessing a wrong use of ConvertFormula, why need it ?…
Check the range address from the code.
No issue with your small attachment via usual ways
whatever using CurrentRegion, End(), Find or UsedRange …Debug.Print ActiveSheet.UsedRange.Columns("A:W").Address

Yes, I just want to pointing towards it.
Only ward "Range" is work there Before "(Application.convertformula)
Not work "myrng " or anything else range variable
Even not "With myrng",Even I try to cover whole
Construct as object like " set myrng =range(Application...).

The point is how this one liner code can work on only
Settled range and not outside range?.

This one liner code is really very important mainly
As it work on column number & main power of it that
It accepts single, contiguous and noncontiguous columns
This power can tremendous help to process on columns
In one shot .

And when any one who maintain with struggle columns arrangement,
As which column should be on which order or which column should be after
Or before which as per his or her logical order or any required logical order/
indexed must need this code to work in one shot who want to work on column numbers.

I also know that it is very very simple & easy to do same job with
Column name like
"Myrng.columns("A;A", "C:C", "F:J").anything you want to do".

And this approach natively supported by excel itself.

But who want to work on column numbers who have
Requirement as number type then this code can work
Like a charm in one shot.

So how to use this code only columns of range and should not
Entire column of sheet?

Oh, I forgot. In this instance, you don't need UNION, since you are not looping through areas within range, or doing different manipulation to each area.
Range("String for each range separated by ,") will do just fine.