• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calling a sub from a different worksheet in the same workbook

gilb

New Member
Hello;

I am trying to execute a sub on a sheet called FILTER from another worksheet called Summary in the same workbook with the following code :

P.S. I am also trying to refresh only one worksheet called Data but the only way I have found to do it is through RefreshAll
'**************************
'Trying to refresh the Data worksheet and execute the filter command on the filter worksheet
Code:
Workbooks(ThisWorkbook.Name).RefreshAll
Call Sheets("FILTER").btnFiltre_Click
The sub code is (by the way this sub is working fine on its own) :

>>> 2nd time -- use code - tags <<<
Code:
Option Explicit

Private Sub btnFiltre_Click()
    Dim zFirstColumn    As String
    Dim n As Long
   
    ActiveWorkbook.Connections("LSUPRD.ZFRTCSV").Refresh
   
    ' clear old data first
    zFirstColumn = "A"
    n = Cells(Rows.Count, zFirstColumn).End(xlUp).Row
    If n > 10 Then
        Rows("11:" & CStr(n)).Delete Shift:=xlUp
    End If

Call btnFilter(n)
End Sub
But I get this error :

68137

Anyone knows how to fix this?

Thank you for your time.
 
Last edited by a moderator:

gilb

New Member
Hi everyone,

NEVERMIND I found out what was wrong, the sub I was calling was private, I changed it to public and it is working fine now.
 
Top