PDA

View Full Version : Calling another macro in same workbook



Rajesh Kr Joshi
08-17-2012, 05:56 PM
Hi I have two following macros in one wrokbook:

1- FormatSheet
2- DeleteData

I wants to trigger DeleteData macro while running FormatSheet macro when in Sheet2 J4 cell value is 0. So it woukd be somthing like this:

run DeleteData if Sheet 2 cell value =0 , if not continue with FormatSheet macro


Thanks
Rajesh

Rick Rothstein
08-17-2012, 10:02 PM
Hi I have two following macros in one wrokbook:

1- FormatSheet
2- DeleteData

I wants to trigger DeleteData macro while running FormatSheet macro when in Sheet2 J4 cell value is 0. So it woukd be somthing like this:

run DeleteData if Sheet 2 cell value =0 , if not continue with FormatSheet macro

It would probably help if we could see your FormatSheet macro (probably seeing the DeleteData macro would be helpful as well) and indicate where in the FormatSheet macro you think you want to run the DeleteData macro at. Posting a copy of your workbook with the macro installed in it would be even better.

Excel Fox
08-17-2012, 10:53 PM
I second Rick on that one. Keeps any assumptions out of the window, thus increasing the chances of a more accurate solution.

From what I gather, is this what you are looking for


If Worksheets("Sheet2").Range("J4").Value = 0 Then
Call DeleteData
End If


https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)

Rick Rothstein
08-17-2012, 11:43 PM
From what I gather, is this what you are looking for


If Worksheets("Sheet2").Range("J4").Value = 0 Then
Call DeleteData
End If
The reason I hesitated in giving the OP an answer is I'm kind of sensing there is a loop iterating in FormatSheet and I wasn't sure if the If..Then you showed should be wrapped around the loop or embedded within it, hence my desire for more information.

Rajesh Kr Joshi
08-18-2012, 12:20 AM
Thanks Rick and Admin :)

This code helped.


Thanks
Rajesh