Macro doesn't call other macro

Fernando14

New Member
Joined
Jun 29, 2021
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
I had this macro working before, but for whatever reason it no longer calls the desired macro. I made changes to the other macro, but none to the "trigger" macro. Here is the trigger macro :
Excel Formula:
Option Explicit
Public FLAGNUM As Integer


Sub worksheet_change(ByVal Target As Range)
Set Target = Range("B13")
FLAGNUM = Target.Value
If Target.Value > 0 Then
 Call Flags
End If


End Sub

Here is the macro that gets triggered if it helps:
Excel Formula:
Option Explicit
Public FLAGNUM As Integer
Public FLAGSW() As Double
Public FLAGSL() As Double
Public FLAGSNORP() As String




Sub Flags()
'
' Flags Macro
'

ReDim FLAGSW(FLAGNUM)
ReDim FLAGSL(FLAGNUM)
ReDim FLAGSNORP(FLAGNUM)
Dim i As Integer

For i = 1 To FLAGNUM
   FLAGSW(i) = InputBox("What is flag " & i & "'s width?")
    FLAGSL(i) = InputBox("What is flag " & i & "'s length?")
    FLAGSNORP(i) = InputBox("Is flag " & i & " nylon or polyester? (Enter N or P)")

Next i

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Nothing happens when I change the target cell's value. I've tried referencing it different ways with no success. Any help is appreciated.
 
Upvote 0
What is the name of the module the "worksheet_change" procedure is in?
 
Upvote 0
Remove this
VBA Code:
Public FLAGNUM As Integer
from the sheet module. All Global variables must be in a standard module.
 
Upvote 0
Solution
Sheet9, whereas the other macro has module9.
OK, you have put it in the correct place

This code of yours looks a little funny too:
VBA Code:
Option Explicit
Public FLAGNUM As Integer


Sub worksheet_change(ByVal Target As Range)
Set Target = Range("B13")
FLAGNUM = Target.Value
If Target.Value > 0 Then
 Call Flags
End If


End Sub
In these type of procedures, you usually do NOT set the Target value - the Target value, by default, is the cell that was just updated.
You don't need to set it, it is automatic.
 
Upvote 0
OK, you have put it in the correct place

This code of yours looks a little funny too:
VBA Code:
Option Explicit
Public FLAGNUM As Integer


Sub worksheet_change(ByVal Target As Range)
Set Target = Range("B13")
FLAGNUM = Target.Value
If Target.Value > 0 Then
 Call Flags
End If


End Sub
In these type of procedures, you usually do NOT set the Target value - the Target value, by default, is the cell that was just updated.
You don't need to set it, it is automatic.
Is this why everytime I change any cell the macro gets triggered? How would I fix this?
 
Upvote 0
Is this why everytime I change any cell the macro gets triggered? How would I fix this?
Yes.

If you only want it to run when B13 is updated, try this:
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = Range("B13").Address Then
        FLAGNUM = Target.Value
        If Target.Value > 0 Then Call Flags
    End If

End Sub
 
Upvote 0
Yes.

If you only want it to run when B13 is updated, try this:
VBA Code:
Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = Range("B13").Address Then
        FLAGNUM = Target.Value
        If Target.Value > 0 Then Call Flags
    End If

End Sub
This worked, thank you!
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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