Chirag R Raval
Member
Dear all users,
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,
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:
Option Explicit
'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
Sub DelSelProcesMultiColumns()
Dim MyRng As Range 'If your approach to access this columns as range object
Dim COLTXT As String 'for give reference of column names as string
'Most Important & useful Note:-
'Range syntax is also acceptable: "C4:C5, C7:C8, C9,C11"
COLTXT = "C3:C8,C10,C12,C14:C19"
' ActiveSheet.Range(Application.ConvertFormula(COLTXT, xlR1C1, xlA1)).Select
'OR
' ActiveSheet.Range(Application.ConvertFormula(COLTXT, xlR1C1, xlA1)).delete
'You can direct access this range through just set this as a range object
'CORE POINT OF THIS CODE IS BELOW
Set MyRng = ActiveSheet.Range(Application.ConvertFormula(COLTXT, xlR1C1, xlA1))
With MyRng 'can access anything (Property Or Methods) after . (Dot)
' With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
'If your already use this range as object, then delete this variable as after work complete , as follows
Set MyRng = Nothing
End With
End Sub