Delete Columns to the right of the range

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
Any help is much appreciated !!

I have this code which delimits the text in the first column with a delimiter...and collates the columns together again. The resultant column after the delimit is on the extreme left of the range. Neverthless - I need to delete three columns to the right of the resultant column (i.e, column B,C & D) and put the cursor focus again to A1 or select A1.

Please help me with the correct code.

Sub Product_Report_Macro()

Cells.Select
Cells.EntireColumn.AutoFit
Range("A3").Select
Columns("A:A").ColumnWidth = 11.5
Rows("1:4").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="[", FieldInfo:=Array(Array(1, 1), Array(2, 1))
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="]", FieldInfo:=Array(Array(1, 1), Array(2, 1))
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("B:H").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveCell.FormulaR1C1 = "Code"
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Font.Bold = True
Selection.End(xlToLeft).Select
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
I want to delete these three columns after doing or completing the above code or steps. Please help.
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Hi

If you could show us a few sample data before/after with a good explanation,
it will help us to understand your problem much better..
 

Watch MrExcel Video

Forum statistics

Threads
1,113,795
Messages
5,544,332
Members
410,603
Latest member
rseckler
Top