Adding to an existing macro

SimonHughes

Well-known Member
Joined
Sep 16, 2009
Messages
507
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am using Excel 2010.

I have created a Macro but now need to add to it but am just not sure how to go about it. The first macro is:

Sub CP_First()
'
' CP_First Macro
'
'
Selection.EntireRow.Delete
Selection.EntireRow.Delete
Selection.EntireRow.Delete
Selection.EntireRow.Delete
Cells.Select
With Selection
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1:Q1").Select
Selection.ColumnWidth = 75
Cells.Select
Cells.EntireRow.AutoFit
Cells.EntireColumn.AutoFit
Range("C3").Select
Selection.EntireColumn.Delete
Range("E3").Select
Selection.EntireColumn.Delete
Range("N3").Select
Selection.EntireColumn.Delete
Rows("1:1").Select
Range("D1").Activate
Selection.ClearFormats
Range("F4").Select
Selection.EntireColumn.Insert
Selection.EntireColumn.Insert
Cells.Select
Range("D1").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Font
.Name = "Calibri"
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Range("H4").Select
End Sub

And I need to add the following onto it

Sub TextToColumn()
'
' TextToColumn Macro
'
'
Columns("E:E").Select
Selection.TextToColumns Destination:=Range("F1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(1, 1)), TrailingMinusNumbers:=True
Range("F1").Select
ActiveCell.FormulaR1C1 = "CC"
Range("G1").Select
ActiveCell.FormulaR1C1 = "MS"
Range("G2").Select
End Sub

I suppose copy paste but doi not want to mess it up, your help appreciated
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You can call your second macro from the first. Just before End Sub (or somewhere else if necessary) put:

Call TextToColumn
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

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