Results 1 to 5 of 5

Call function not working

Threaded View

  1. #1
    Registered User
    Join Date
    06-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    41

    Call function not working

    Hi guys i am trying to call a macro which i have recorded in a spreadsheet, dont know what is happening to it but it seems to be giving me an error. I am using a simple comand buttone to call 2 macros, one of them is working perfectly but the other one is giving me an error. below is the code:

    Private Sub CommandButton1_Click()
    
      RngSelect.Show      'this is a userform which opens on this command button
      
      Call period          'this is the macro which is not working
       
      Call Search        'this macro is working fine
      
      
    End Sub
    On clicking this button vba gives me a compile error, saying 'Expected variable or procedure,not module'.

    However if i omit this one and just have the second macro it works fine.
    I have tried moving this to other places in the worksheet to trigger it but everywhere it is giving me an error. Thus im guessing it might be an error with the macro itself which is as below:

    Sub period()
    '
    ' period macro
    '
    Application.EnableEvents = False
        With Sheets("Sheet1")
            .Range("C63").Select
            Selection.copy
            Range("C64").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    '
        With Sheets("Pivot for Map")
            .PivotTables("PivotTable1").PivotFields("YrPrComp").CurrentPage = _
            Sheets("Sheet1").Range("E64").Value
          
            With Sheets("Sheet1")
                Range("C66:C193").copy
                Range("E66").Select
                Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                Application.CutCopyMode = False
            End With
        End With
        Sheets("Pivot for Map").PivotTables("PivotTable1").PivotFields("YrPrComp").CurrentPage = _
            Sheets("Sheet1").Range("C64").Value
        Sheets("Sheet1").Select
    End With
    
    Application.EnableEvents = True
    End Sub
    Could you guys have a look at this and let me know what is going wrong here, i was working on this a couple of hours ago and both the macros were working fine, no problems at all, dont know why its doing this now.

    Regards,
    Abz
    Last edited by abz; 07-19-2010 at 07:16 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1