Calling a Sub within the Main Macro

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
I am having issues with this string of code:

Sub Format_Workbook_Pt2()

Sub ConvertTextToNumber()
Sheets("All_Data").Select
Range("C:C").Select
Selection.TextToColumns _
Destination:=Range("A:A"), _
DataType:=xlDelimited
End Sub
End Sub


I wanted to keep Sub Frmat_Worbook_Pt2() as the main macro as I build more code into the main macro.
Thanks!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You need to do it like
Code:
Sub Format_Workbook_Pt2()
   Call ConvertTextToNumber
End Sub
Sub ConvertTextToNumber()
Sheets("All_Data").Select
Range("C:C").Select
Selection.TextToColumns _
Destination:=Range("A:A"), _
DataType:=xlDelimited
End Sub
 
Upvote 0
You CANNOT imbed one macro inside another. They would be two separate macros, and you would just call one from the other:
Code:
[COLOR=#333333]Sub Format_Workbook_Pt2()[/COLOR]
[B]    [COLOR=#0000ff]Call ConvertTextToNumber[/COLOR][/B]
End Sub

[COLOR=#333333]Sub ConvertTextToNumber()[/COLOR]
[COLOR=#333333]    Sheets("All_Data").Select[/COLOR]
[COLOR=#333333]    Range("C:C").Select[/COLOR]
[COLOR=#333333]    Selection.TextToColumns _[/COLOR]
[COLOR=#333333]    Destination:=Range("A:A"), _[/COLOR]
[COLOR=#333333]    DataType:=xlDelimited[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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