Private Sub Worksheet_Calculate()

Rubber Beaked Woodpecker

Board Regular
Joined
Aug 30, 2015
Messages
203
Office Version
  1. 2021
Formulas I am ok with but vba gets me every time.
Please could somebody tidy the following so it works ok;

Private Sub Worksheet_Calculate()

If Range("r1") = "Finished 0" Then Call Macro1
If Range("r1") = "Finished 1" Then Call Macro2
If Range("r1") = "Finished 2" Then Call Macro3
If Range("r1") = "Finished 3" Then Call Macro4
If Range("r1") = "Finished 4" Then Call Macro5
If Range("r1") = "Finished 5" Then Call Macro6
If Range("r1") = "Finished 6" Then Call Macro7
If Range("r1") = "Finished 7" Then Call Macro8
If Range("r1") = "Finished 8" Then Call Macro9
If Range("r1") = "Finished 9" Then Call Macro10
If Range("r1") = "Finished 10" Then Call Macro11
If Range("r1") = "Finished 11" Then Call Macro12
If Range("r1") = "Finished 12" Then Call Macro13
If Range("r1") = "Finished 13" Then Call Macro14
If Range("r1") = "Finished 14" Then Call Macro15
If Range("r1") = "Finished 15" Then Call Macro16
If Range("r1") = "Finished 16" Then Call Macro17
If Range("r1") = "Finished 17" Then Call Macro18
If Range("r1") = "Finished 18" Then Call Macro19
If Range("r1") = "Finished 19" Then Call Macro20
If Range("r1") = "Finished 20" Then Call Macro21
If Range("r1") = "Finished 21" Then Call Macro22
If Range("r1") = "Finished 22" Then Call Macro23
If Range("r1") = "Finished 23" Then Call Macro24
If Range("r1") = "Finished 24" Then Call Macro25
If Range("r1") = "Finished 25" Then Call Macro26

End Sub

Many thanks RBW
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
maybe

VBA Code:
Private Sub Worksheet_Calculate()
    Dim i As Long
    For i = 0 To 25
       If Range("r1") = "Finished " & i Then Application.Run "Macro" & i + 1
    Next i
End Sub

but really wondering why you have 26 macros presumably doing more or less same thing?

Dave
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top