• 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.

Call function in VBA does not work

Dear all,


I want to create on macro which runs the folling two macro's:


1. first filter macro:


Sub FILTER_VISIE()


Sheets("Visie uitlijnen").Range("B3:r16").AdvancedFilter Action:= _

xlFilterCopy, CriteriaRange:=Range("B1:R2"), CopyToRange:=Range("C4:R4"), _

Unique:=False


End Sub


2. second filter macro:


Sheets("Strategie cascaderen").Range("B3:r16").AdvancedFilter Action:= _

xlFilterCopy, CriteriaRange:=Range("B1:R2"), CopyToRange:=Range("B4:R4"), _

Unique:=False


I've tried to run both macro's like this:


Sub RUNFILTERMACROs()


Call FILTER_VISIE

Call FILTER_STRATEGIE


End Sub


But this doesn´t work. Anybody suggestions on how I can make this work?


Dear regards,


Marc
 
Hi,


Call functions works for sure ‼   You can follow your code via the F8 key …


Code correction because when worksheet is not the active sheet, you must specify it into each range :

[pre]
Code:
Sub FILTER_VISIE()
With ActiveWorkbook.Worksheets("Visie uitlijnen")
.[B3:R16].AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.[B1:R2}, _
CopyToRange:=.[C4:R4], Unique:=False

End With
End Sub
[/pre]

 
 
Can you elaborate on what you mean by "doesn't work". Does the RUNFILTERMACROs crash, does it run but not do anything, do the two slave macros crash?
 
Thanks for your feedback Mark L. But it still doesn't work when I enter the code like:


Sub FILTER_VISIE()


With ActiveWorkbook.Worksheets("Visie uitlijnen").Range("B3:r16").AdvancedFilter Action:= _

xlFilterCopy, CriteriaRange:=Range("B1:R2"), CopyToRange:=Range("C4:R4"), _

Unique:=False


End With


End Sub

Sub RUNFILTERMACROs()


Call FILTER_VISIE

Call FILTER_STRATEGIE


End Sub


Sub FILTER_STRATEGIE()


With ActiveWorkbook.Worksheets("Strategie cascaderen").Range("B3:r16").AdvancedFilter Action:= _

xlFilterCopy , CriteriaRange:=Range("B1:R2"), CopyToRange:=Range("B4:R4"), _

Unique:=False


End With


End Sub


I get a syntax error. Did i make a format mistake?


Dear regards,


Marc
 
Hi Marc ,


Can you try this ?

Code:
Sub RUNFILTERMACROs()
 
Call FILTER_VISIE
Call FILTER_STRATEGIE
 
End Sub
 
Sub FILTER_VISIE()
 
With ActiveWorkbook.Worksheets("Visie uitlijnen")
.Range("B3:R16").AdvancedFilter Action:= _
xlFilterCopy, CriteriaRange:=.Range("B1:R2"), CopyToRange:= _
ActiveSheet.Range("C4:R4"), Unique:=False
End With
 
End Sub
 
Sub FILTER_STRATEGIE()
 
With ActiveWorkbook.Worksheets("Strategie cascaderen")
.Range("B3:R16").AdvancedFilter Action:= _
xlFilterCopy, CriteriaRange:=.Range("B1:R2"), CopyToRange:= _
ActiveSheet.Range("B4:R4"), Unique:=False
End With
 
End Sub
Narayan
 
Thanks for your feedback Mark L. But it still doesn't work when I enter the code

Juste 'cause it's not my correction code, you still with the same problem ‼


Read the With VBA help, see where are placed points in my code and NARAYANK's …
 
Marc


This post will be erased on Sunday as Chandoo is introducing a new forum


Refer: http://chandoo.org/forums/topic/forum-migration-freezing-on-23aug2013-important


I'd suggest reposting the question on Monday
 
Does any one see and read the Large green sticky at the top of the sticky lisT


*******************DO NOT POST ANYTHING THIS WEEKEND AS IT WILL DISAPPEAR INTO THE EITHER***************READ THE STICKY************Forum Migration & Freezing on 23AUG2013 [IMPORTANT]************
 
Back
Top