0

I'm pretty new to VBA .Here is my problem: I have a dropdown list in A4 with ListItem1 to ListItem7.I want to autofill A6 t0 A11 when selecting ListItem1,ListItem2 ect...I've recorded the Macro:

    Range("A6").Select
    ActiveCell.FormulaR1C1 = "67"
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "87"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = "rty-u"
    Range("A9").Select
    ActiveCell.FormulaR1C1 = "kjty"
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "erty"
    Range("A11").Select
    ActiveCell.FormulaR1C1 = "u"
    Range("A6:A11").Select
    Selection.ClearContents
    Range("A6").Select
    ActiveCell.FormulaR1C1 = "9867"
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "4567"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = "ghty"
    Range("A9").Select
    ActiveCell.FormulaR1C1 = "3454"
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "klii"
    Range("A6:A10").Select
    Selection.ClearContents
    Range("A6").Select
    ActiveCell.FormulaR1C1 = "23567"
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "9867"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = "hjytrer"
    Range("A9").Select
    ActiveCell.FormulaR1C1 = "bnjg"
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "987"
    Range("A6:A10").Select
    Selection.ClearContents
    Range("A6").Select
    ActiveCell.FormulaR1C1 = "56456"
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "9876"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = "45678"
    Range("A9").Select
    ActiveCell.FormulaR1C1 = "mjtyu"
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "nbvc"
    Range("A11").Select
    ActiveCell.FormulaR1C1 = "fgtre"
    Range("A6:A11").Select
    Selection.ClearContents
End Sub

Any helps?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Houeto
  • 13
  • 3
  • You don't seem to need code as much as you need a plan. (A) From your drop-down you select 1 of 7 items. (B) In A6:A11 you wish to enter 6 presumably different values. (C) If these six values should be different for each of the possible 7 selections in the drop-down you would need 7 lists of 6 items each. Where are they? (D) Depending upon which item is selected from the drop-down a different list would be applied to A6:A11. How do you intend to identify the 7 lists by means of the selection made? – Variatus Jan 30 '19 at 03:28
  • I advise not using `select` since it will slow down your project. – Giovanni Di Toro Jan 30 '19 at 03:29
  • @Variatus To your question (C) I wanted to hard code the 6 items to be autopopulated for each selection in 7 ListItems(They are not in a given table).7 lists is identified by ListItem1,ListItem2,...ListItem7 – Houeto Jan 30 '19 at 03:47
  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Pᴇʜ Jan 30 '19 at 07:43

0 Answers0