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

multi macros at a time

bharath

Member
hi,

Function FeedProduct(x As String)
ActiveWorkbook.Worksheets("bk").Range("P1") = x
End Function

Sub new1()
End Sub

HERE I WANT TO USE BOTH MACROS IN ONE CLICK
 
Dear Bharath...

I just want to know that, you want to call a procedure from a function or you want to call a function from a procedure?

If you want to call a function from a procedure, then please put your function name in between sub and end sub

Regarding first one, call procedure from function, may be same process will be applied.(not sure)
 
Ditto to what vijay said, but disregarding your example, the syntax to call 2 macros would be something like:
Code:
Option Explicit

Sub Slave1()
MsgBox "First macro"
End Sub

Sub Slave2()
MsgBox "Second macro"
End Sub

Sub CallingSub()
Call Slave1
Call Slave2
End Sub
 
I'd like to hear more about what your trying to do
Often if we know the detail we can advise a work around
 
hi,
1) Function FeedProduct(x As String)
ActiveWorkbook.Worksheets("bk").Range("P1") = x
End Function

2) Sub new1()
End Sub

Here I want to use function macro along with second macro.
Means Data depends on 1 macro with that value result will be come by using 2 macro.
The Problem is i can get result by running separately (1 next 2) But i cant include 2 macro in 1 macro
like....
" Function FeedProduct(x As String)
ActiveWorkbook.Worksheets("bk").Range("P1") = x
End Function
'Sub new1()
End Sub
" it is not running
actually i use 1 macro in hyperlink formula with that x value come by with that 2 macro will have to run automatically.

Thanks.
 
Hi, bharath!
Check the uploaded, it's what you asked for. If any change required you'd better start elaborating.
Regards!
 

Attachments

  • multi macros at a time (for bharath at chandoo.org).zip
    3.7 KB · Views: 4
sorry i may not explain correctly
ok i will upload macros
1)
Function FeedProduct(x As String)

ActiveWorkbook.Worksheets("Feed").Range("P1") = x
End Function
2)
Function Area(y As String)

ActiveWorkbook.Worksheets("Feed").Range("O1") = y
End Function
3)
Public Sub FeedTrend()
Application.ScreenUpdating = False
Sheets("DB").Activate
Selection.AutoFilter
ActiveSheet.Range("$j$1:$Bj$300").AutoFilter Field:=10, Criteria1:="TRUE"
ActiveSheet.Range("$k$1:$Bk$300").AutoFilter Field:=11, Criteria1:="TRUE"
' Selection.AutoFilter
Range("C2:I500").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Feed").Select

Range("O4").Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("DB").Activate
' Range("A1:K300").unSelect
ActiveSheet.Range("$A$1:$k$300").AutoFilter Field:=1
Selection.AutoFilter
Range("A1").Select
Application.CutCopyMode = False
Sheets("Feed").Select
Range("E4").Select
Application.ScreenUpdating = True

End Sub
 
Hi Bharath ,

More than a week has passed without your problem getting resolved ; if you upload your workbook , you will get a solution within the next one hour.

Narayan
 
Ah, I see now that you are wanting to call a Macro from a Function, which in turn is being triggered by a Hyperlink. You can't call a macro that way.

However, a better way would be to use the native XL function to perform the calculations. Check out the attached. Rather than having a macro transfer all the data and then SUM, I used the SUMIFS function which uses O1 and P1 to trigger the changes. Now the chart updates as user moves the mouse.
 

Attachments

  • Feed Trend Improved.xlsm
    51.9 KB · Views: 2
Back
Top