Running more than one VBA code on a sheet

Is there something specific I need to do when creating more than one VBA code on a worksheet?

 

It seems that when I have more than one code - only one or the other wants to work for me.

 

Sheri

If you have created more than one macro and want to run multiple macros at once, create another macro that runs the other macros:

Public Sub MySuperMacro()

    Macro1
    Macro2
    Macro3
    ...

End Sub

Kevin

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thanks Kevin,

 

With what I have so far, where would I place what you typed?

 

This is what I have right now - which works great to hide rows.

 

Private Sub Worksheet_Change(ByVal Target As Range)
      If Not Intersect(Range("F8"), Target) Is Nothing Then
          Application.EnableEvents = False
          Range("A9:A17").EntireRow.Hidden = (UCase(Range("F8")) = "NO")
          Application.EnableEvents = True
    End If
        If Not Intersect(Range("F18"), Target) Is Nothing Then
          Application.EnableEvents = False
          Range("A19:A30").EntireRow.Hidden = (UCase(Range("F18")) = "NO")
          Application.EnableEvents = True
      End If
  End Sub

 

This is what I want to add, which does not work when I add it to the above codes:

 

If Not Intersect(Target, Range("F5")) Is Nothing Then
If Target.Value = "NO" Then
Range("F9").Value = "N/A"

Else

Range("F9").Value = ""
End If
End If

 

 

Can you help?

 

Sheri

 

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("F8"), Target) Is Nothing Then
        Application.EnableEvents = False
        Range("A9:A17").EntireRow.Hidden = (UCase(Range("F8")) = "NO")
        Application.EnableEvents = True
    End If
    If Not Intersect(Range("F18"), Target) Is Nothing Then
        Application.EnableEvents = False
        Range("A19:A30").EntireRow.Hidden = (UCase(Range("F18")) = "NO")
        Application.EnableEvents = True
    End If
    If Not Intersect(Target, Range("F5")) Is Nothing Then
        Application.EnableEvents = False
        If Target.Value = "NO" Then
            Range("F9").Value = "N/A"
        Else
            Range("F9").Value = ""
        End If
        Application.EnableEvents = True
    End If
End Sub

Kevin

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 22, 2024 Views 7,138 Applies to: