Macro that overrides previous macro from a drop down.

khodnik

New Member
Joined
Jul 10, 2015
Messages
3
Hi there,

I am attempting to use a macro that is connected to the answers in a drop-down menu. The code I'm using is:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("$G$78")) Is Nothing Then
Select Case Range("$G$78")
Case "1 Product": Product1
Case "2 Products": Product2
Case "3 Products": Product3
End Select
End If
End Sub


The macro is set up to insert a few rows that gather information about each product, but of course this is dependent on how many products someone has. The issue I'm having is that if I select 1 Product, then go back and select 2 Products, the rows for 2 products are simply added to the bottom of the first choice. What I'm looking for is that if someone changes their selection, the new macro overrides the first. Is this possible?

Thank you for your help!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
you need go post the other three macros that this one calls, also.
 
Upvote 0
Hi JLGWhiz, I was testing the dropdown functionality out, so really I haven't quite figured out the exact lines that would be inserted, but the macro is set up to simply insert a row with a header that says "PRODUCT 1" and if there are two products, two headers would be inserted, and so on. The only issue is that if I select product 1 and then product 2, three rows in total are added versus just the two that are needed if the dropdown is changed. Does this make sense?
 
Upvote 0
Hi JLGWhiz, I was testing the dropdown functionality out, so really I haven't quite figured out the exact lines that would be inserted, but the macro is set up to simply insert a row with a header that says "PRODUCT 1" and if there are two products, two headers would be inserted, and so on. The only issue is that if I select product 1 and then product 2, three rows in total are added versus just the two that are needed if the dropdown is changed. Does this make sense?

The macro that was posted inserts nothing. It calls another macro to do something. Without seeing the other macros, it is difficult to offer any advice on what changes are needed to achieve your solution.
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,946
Members
449,198
Latest member
MhammadishaqKhan

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