Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49948

[SOLVED] Macro Buttons - Sub or Function not defined?

$
0
0
I am having an issue with creating macros in my sheet. The macros individually work, I am just trying to assign buttons to them. And maybe I am going about this all the wrong way, one macro to show certain cells, another macro to hide them - not sure if that can be done with one macro but then I am new to macros.

However, with the technique I am using, the two macros individually work. But the buttons will/will not work. In example, below:

Code:

Private Sub ToggleButton36_Click()
If ToggleButton36.Value = True Then
        Call Y4BHPSO2
    Else
        Call N4BHPSO2
    End If
End Sub

Code:

Private Sub ToggleButton39_Click()
If ToggleButton39.Value = True Then
        Call Y4HPSO2
    Else
        Call N4HPSO2
    End If
End Sub

The first button works, the second button does not work. I have this all throughout my sheet, currently have 43 buttons with about half of them working and half of them not working. When they do not work, it tells me "Compile Error. Sub or Function not defined." But the Sub values are identical, why would one work and other does not?

The macros for these buttons are here:
Code:

Sub Y4BHPSO2()
'
' Y4BHPSO2 Macro
'

'
    Rows("72:72").Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.Range("A1").Select
End Sub
Sub N4BHPSO2()
'
' N4BHPSO2 Macro
'

'
    Rows("72:72").Select
    Selection.EntireRow.Hidden = True
    ActiveSheet.Range("A1").Select
End Sub
Sub Y4HPSO2()
'
' Y4HPSO2 Macro
'

'
    Rows("73:73").Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.Range("A1").Select
End Sub
Sub NHPSO2()
'
' N4HPSO2 Macro
'

'
    Rows("73:73").Select
    Selection.EntireRow.Hidden = True
    ActiveSheet.Range("A1").Select
End Sub


Viewing all articles
Browse latest Browse all 49948

Trending Articles