宏在数据验证列表中运行每个数据点

时间:2016-06-25 00:50:46

标签: vba validation macros

我想编写一个宏,它运行在不同工作表上的两个数据验证列表中的每个数据点。这是我写的代码:

<html>
<head>
    <title>BraintreePHPExample</title>
    <link rel=stylesheet type=text/css href="css/app.css">
    <link rel=stylesheet type=text/css href="css/overrides.css">
    <script src="javascript/vendor/jquery-2.1.4.min.js"></script>
    <script src="javascript/vendor/jquery.lettering-0.6.1.min.js"></script>
    <script src="javascript/demo.js"></script>
</head>
<body>

    <header class="main">
    <div class="container wide">
        <div class="content slim">
            <div class="set">
                <div class="fill">
                    <a class="pseudoshop" href="/">PSEUDO<strong>SHOP</strong></a>
                </div>

                <div class="fit">
                    <a class="braintree" href="https://developers.braintreepayments.com/guides/drop-in" target="_blank">Braintree</a>
                </div>
            </div>
        </div>
    </div>

    <div class="notice-wrapper">
            </div>
</header>

    <div class="wrapper">
        <div class="checkout container">

            <header>
                <h1>Hi, <br>Let's test a transaction</h1>
                <p>
                    Make a test payment with Braintree using PayPal or a card
                </p>
            </header>

            <form method="post" id="payment-form" action="/braintree_php_api/public_html/checkout.php">
                <section>
                    <div class="bt-drop-in-wrapper">
                        <div id="bt-dropin"></div>
                    </div>

                    <label for="amount">
                        <span class="input-label">Amount</span>
                        <div class="input-wrapper amount-wrapper">
                            <input id="amount" name="amount" type="tel" min="1" placeholder="Amount" value="10">
                        </div>
                    </label>
                </section>

                <button class="button" type="submit"><span>Test Transaction</span></button>
            </form>
        </div>
    </div>

    <script src="https://js.braintreegateway.com/v2/braintree.js"></script>
    <script>
        var checkout = new Demo({
            formID: 'payment-form'
        })
        var client_token = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiJiNmZhMDYxN2IxZjU2MjQzZGE0NWY4Mjk5YjEzYmRhNGEzZDEyNzM4MmMyOGQxOWY5NGI0OTJkMjgwODlkMTllfGNyZWF0ZWRfYXQ9MjAxNi0wNi0yNVQwMDo0MDo1My4xODc0MTUyN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VcmwiOm51bGwsImFsbG93SHR0cCI6dHJ1ZSwiZW52aXJvbm1lbnROb05ldHdvcmsiOnRydWUsImVudmlyb25tZW50Ijoib2ZmbGluZSIsInVudmV0dGVkTWVyY2hhbnQiOmZhbHNlLCJicmFpbnRyZWVDbGllbnRJZCI6Im1hc3RlcmNsaWVudDMiLCJiaWxsaW5nQWdyZWVtZW50c0VuYWJsZWQiOnRydWUsIm1lcmNoYW50QWNjb3VudElkIjoiaWhlbHByIiwiY3VycmVuY3lJc29Db2RlIjoiVVNEIn0sImNvaW5iYXNlRW5hYmxlZCI6ZmFsc2UsIm1lcmNoYW50SWQiOiJ3bXQyaGdubWM3cXFtcHBmIiwidmVubW8iOiJvZmYifQ==";

        braintree.setup(client_token, "dropin", {
            container: "bt-dropin"
        });
    </script>
</body>
</html>

我收到了错误:

 Sub selfrefpop()

    Dim cell1           As Excel.Range
    Dim cell2           As Excel.Range
    Dim SO              As Excel.Range
    Dim AF              As Excel.Range
    Dim rgDV1           As Excel.Range
    Dim rgDV2           As Excel.Range
    Dim activews        As Worksheet
    Dim dashboard       As Worksheet

      Set activews = ActiveWorkbook.ActiveSheet

      Set dashboard = Sheets("Dashboard")

      Set SO = activews.Range("D8")

      Set AF = dashboard.Range("L17")

      Set rgDV1 = activews.Range(SO.Validation.Formula1)

      With dashboard
        Set rgDV2 = .Range(AF.Validation.Formula1)
      End With

        For Each cell1 In rgDV1
            rgDV1.Value = cell1.Value

            For Each cell2 In rgDV2
                rgDV2.Value = cell2.Value
            Next
        Next

End Sub

错误说“对象'_Worksheet'的方法'范围'失败,错误1004”

我知道它是一个引用错误。但在解决问题时遇到了问题。

感谢。

1 个答案:

答案 0 :(得分:0)

您正在尝试使用Set rgDV2 = .Range(AF.Validation.Formula1),但AF.Validation.Formula1不是范围。如果您使验证公式成为引用其应该有效的百分比列表的范围。