从另一个单元格中选择下拉列表中的项目时自动填充单元格

时间:2019-01-30 02:58:22

标签: excel vba autofill

我是VBA的新手,这是我的问题: 我在A4中有一个从ListItem1到ListItem7的下拉列表。我想在选择ListItem1,ListItem2等时自动填充A6 t0 A11 ...我已经记录了宏:

    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

有帮助吗?

0 个答案:

没有答案