UserForm Initialize - 对象'_Global'的方法'范围'失败 [英] UserForm Initialize - Method 'Range' of object '_Global" failed

查看:147
本文介绍了UserForm Initialize - 对象'_Global'的方法'范围'失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为UserForm上的控件赋值,作为UserForm初始化子例程的一部分。

I am assigning values to controls on my UserForm as part of the initialize sub routine of the UserForm.

我有一个名为INP_EV的命名范围,它指的是一个公式我把它放在了一起。公式目前的计算结果为10.我通过名称管理器创建了这个命名范围,并且它具有"工作簿"范围。

I have a named range called INP_EV, which refers to a formula I have put together. The formula currently evaluates to 10. I created this named range through the name manager and it has 'Workbook' scope.

调试我的'初始化'子例程,我收到方法对象'_Global'的'范围'在以下行中出现错误消息:

Debugging my 'initialise' sub routine, I receive the Method 'Range' of object '_Global" failed error message at the following line:

tb_ACQ_EV.value = Range("INP_EV").value

我试图将命名范围INP_EV的值分配给我的UserForm上的文本框对象,并命名为tb_ACQ_EV。在查找/计算命名范围INP_EV的值时似乎存在一些问题。

I am trying to assign the value of the named range INP_EV to a textbox object which is on my UserForm and is named tb_ACQ_EV. It seems as if there's some issue in finding/computing the value of the named range INP_EV.

我尝试将当前的INP_EV公式输入到单元格中并将INP_EV命名范围引用到该单元格。在这种情况下我没有收到错误消息,但我不希望找到所有"公式"类型名称范围的单元格。

I have tried entering the current INP_EV formula into a cell and referring the INP_EV named range to that cell. I do not receive the error message in this case, but I would prefer not to find cells for all of my 'formula'-type names ranges.

提前致谢。

推荐答案

选项1:指定包含单元名称INP_EV的工作表的名称:

Option 1: specify the name of the worksheet that contains the cell names INP_EV:

tb_ACQ_EV.Value = Worksheets("SomeSheet").Range("INP_EV").Value

选项2:使用工作簿的Names集合:
$

Option 2: use the Names collection of the workbook:

tb_ACQ_EV.Value = ActiveWorkbook.Names("INP_EV").RefersToRange.Value


这篇关于UserForm Initialize - 对象'_Global'的方法'范围'失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆