How to call a sub from a module in a CommandButton_Click code?

I want to run a sub named "Sort" at the end to the below code.  I tried "Call Sort" and "Sort"

Public Sub CommandButton21_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("New Player")
Set pasteSheet = Worksheets("Players")

'''''''''
Dim FindString As String
Dim Rng As Range
FindString = Sheets("New Player").Range("D9")
If Trim(FindString) <> "" Then
    With Sheets("Players").Range("D:D") 'searches all of column A
        Set Rng = .Find(What:=FindString, _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False)
        If Not Rng Is Nothing Then
            'Application.Goto Rng, True 'value found
            MsgBox "Player already exists" 'value not found
        Else
            copySheet.Range("A9:C9").Copy
            pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
        End If
    End With
End If
Application.CutCopyMode = False
Application.ScreenUpdating = True
Range("B1:B3").Clear
'Call Sort
'Sort
End Sub

Open in new window

kbay808Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MacroShadowCommented:
As long as the sub is accessible either will work. Make sure the sub is in a regular module and it's scope isn't private.
0
kbay808Author Commented:
It's in a regular module (Module1).  Here is the sub that I'm trying to run.

Sub Sort()
Sheets("Players").Range("A1:C1000").Sort _
Key1:=Range("A1"), Header:=xlYes
End Sub

Open in new window

0
MacroShadowCommented:
Sub Sort()
    Sheets("Players").Range("A1:C1000").Sort _
    Key1:=Sheets("Players").Range("A1"), Header:=xlYes
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Saurabh Singh TeotiaCommented:
Sort is a key word thats might be the reason it's giving you an error use this...

Sub Srtvalues()
dim lrow as long
lrow=sheets("Players".cells(cells.rows.count,"A").end(xlup).row
Sheets("Players").Range("A1:C"& lrow).Sort Key1:=Range("A1"), Header:=xlYes
End Sub

Open in new window


And now you call Srtvalues from your code and it should go..Plus i make your last row dynamic which was restricted to 1000 earlier..

Saurabh...
0
kbay808Author Commented:
Thanks!!!  That worked perfect.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.