JosephALin
New Member
- Joined
- May 13, 2016
- Messages
- 13
Hi, everybody! I am very new to excel vba and macro. Here is the situation I have now:
I created a data validation drop down menu that contains a list of names, which I expected to summon an unique macro that is linked to it.
The data validation code is as below:
And the macro code format is like this, the only difference among all of them is the cell number in the first formula array,
And now the situation that I encounter is that, when I click one of the item in the dropdown menu, Excel prints out the right content, however, after that, no matter which item I choose from the list, it prints out the exact same content as the first item I chose, which is really weird. I can tell teh excel is running the correct macro code in behind, since the screen change showcases every procedure in it, only at the last step, the right content will be covered. I couldn't figure out why this is happening, is there anything wrong with my code or macro? </div></div>
Please help me solve this problem, thanks!
I created a data validation drop down menu that contains a list of names, which I expected to summon an unique macro that is linked to it.
The data validation code is as below:
HTML:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$B$3" Then On Error GoTo bm_Safe_Exit Application.EnableEvents = False Select Case Target.Value2 Case "ABCP" Call Macro1 Case "Accounting Policy" Call Macro2 Case "Audit Committee" Call Macro3 Case "Auto" Call Macro4 Case "Auto Issuer Floorplan" Call Macro5 Case "Auto Issuers" Call Macro6 Case "Board of Director" Call Macro7 Case "Bondholder Communication WG" Call Macro8 Case "Canada" Call Macro9 Case "Canadian Market" Call Macro10
Case Else 'Do Nothing End Select End Ifbm_Safe_Exit: Application.EnableEvents = TrueEnd Sub
HTML:
Sub Macro1()'' Macro1 Macro'
'Range("F2").FormulaArray = _ "=IF(COUNTIF(Database!R2C35:R10000C35,Committees!R2C1)>=ROW(Committees!R2C:RC),INDEX(Database!R2C[-5]:R10000C[-5],SMALL(IF(Database!R2C35:R10000C35=Committees!R2C1,ROW(Database!R2C35:R10000C35)-ROW(Database!R2C35)+1),ROWS(Committees!R2C:RC))),"""")"Range("F2").AutoFill Destination:=Range("F2:T2"), Type:=xlFillDefaultRange("F2:T2").AutoFill Destination:=Range("F2:T6000")
Sheets("Reports").Range("F2").FormulaR1C1 = "=IF(ISERROR(Committees!RC),"""",Committees!RC)"Sheets("Reports").Range("F2").AutoFill Destination:=Sheets("Reports").Range("F2:T2"), Type:=xlFillDefaultSheets("Reports").Range("F2:T2").AutoFill Destination:=Sheets("Reports").Range("F2:T6000")
End Sub
And now the situation that I encounter is that, when I click one of the item in the dropdown menu, Excel prints out the right content, however, after that, no matter which item I choose from the list, it prints out the exact same content as the first item I chose, which is really weird. I can tell teh excel is running the correct macro code in behind, since the screen change showcases every procedure in it, only at the last step, the right content will be covered. I couldn't figure out why this is happening, is there anything wrong with my code or macro? </div></div>
Please help me solve this problem, thanks!