首页 > 解决方案 > VBA 使用字符串作为范围

问题描述

我的 VBA 工具需要帮助。

在我的程序中,我定义了一个字符串关键字:

    Public Sub SetKeyword()

        Call Define_Variables.variables
        Call Database.Allocation

        strKeyword="KINDACC"

现在我想用我的字符串关键字设置范围关键字的名称,所以它看起来像这样:

    Public Sub SetKeyword()


        Call Define_Variables.variables
        Call Database.Allocation


        strKeyword="KINDACC"
        rngKeyword= r_KINDACC

     End Sub

在我的模块“数据库”中,我已经定义了那些 r_strKeywords:

    Sub Allocation()


    'General accident information
     ...
     Set r_KINDACC = Worksheets("Database").Range("N4:N14")
     End sub

所以稍后我想用我的 GUI 定义一个字符串关键字,我的程序会自动用我的字符串关键字定义我的范围关键字:

     Public Sub SetKeyword()


          Call Define_Variables.variables
          Call Database.Allocation


          strKeyword=blabla
          rngKeyword= r_strKeyword

    End Sub

那可能吗?我希望它不会太混乱

谢谢!!

维多利亚

标签: vbaexcel

解决方案


推荐阅读