Help with Code for Ambiguous Error

suzette0735

New Member
Joined
Jul 12, 2023
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi! I have two drop downs that change the format of the document I am working on. The first allows the user to choose which sheet they will work on (Estimate sheet, and Warehouse/Installer Copy), the second will update the sheet Estimate sheet so it will print with select rows/columns. I would like a third drop down to do the same as the latter too, but do not know if I am doing this right. Or if there is an easier way? Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("F1"), Target) Is Nothing Then
Application.EnableEvents = False
Select Case Target.Value
Case "Estimate/Bid Sheet/Master": estimatebidsheet
Case "Warehouse/Installer Copy": warehousecopy

End Select
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("H1"), Target) Is Nothing Then
Application.EnableEvents = False
Select Case Target.Value
Case "Entire Sheet": ENTIRESHEET
Case "Base Bid Pg 1, Base TTL": BaseBidPg1BaseTTL

End Select
Application.EnableEvents = True
End If
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You can't use same procedure name within one module, so you need to combine the code like this.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Range("F1"), Target) Is Nothing Then
        Select Case Target.Value
            Case "Estimate/Bid Sheet/Master": estimatebidsheet
            Case "Warehouse/Installer Copy": warehousecopy
        End Select
    ElseIf Not Intersect(Range("H1"), Target) Is Nothing Then
        Select Case Target.Value
            Case "Entire Sheet": ENTIRESHEET
            Case "Base Bid Pg 1, Base TTL": BaseBidPg1BaseTTL
        End Select
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Solution
You can't use same procedure name within one module, so you need to combine the code like this.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Range("F1"), Target) Is Nothing Then
        Select Case Target.Value
            Case "Estimate/Bid Sheet/Master": estimatebidsheet
            Case "Warehouse/Installer Copy": warehousecopy
        End Select
    ElseIf Not Intersect(Range("H1"), Target) Is Nothing Then
        Select Case Target.Value
            Case "Entire Sheet": ENTIRESHEET
            Case "Base Bid Pg 1, Base TTL": BaseBidPg1BaseTTL
        End Select
    End If
    Application.EnableEvents = True
End Sub
thank you so much!!
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,670
Members
452,993
Latest member
FDARYABEE

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