在Excel中进行VBScripting [英] VBScripting in Excel

查看:84
本文介绍了在Excel中进行VBScripting的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我创建了两个工作簿,一个工作簿包含一组下拉列表,另一个工作簿包含数据。

我试图使用VBScript将WB2中的数据绑定到WB1中的下拉菜单。

问题是,下拉列表没有显示数据,而是显示内部的空行..

这是我的代码:

 私人  Sub  Worksheet_Change( ByVal 目标 As 范围)
Dim wbSource
Dim cboTemp As OLEObject
Dim ws As 工作表
设置 ws = ActiveSheet
设置 wbSource = Workbooks.Open( .. \ InputData.xlsx
设置 cboTemp = ws.OLEObjects( ComboBox4
开启 错误 恢复 下一步
使用 cboTemp
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 15
.Height = Target.Height + 5
.ListFillRange = '[ InputData.xlsx]可用性'!$ B $ 2:$ C $ 9
.LinkedCell = Target.Address
结束 使用
cboTemp.Activate
wbSource.Close
结束 Sub



请帮助我获取值绑定到下拉列表

解决方案

B


2:


C

Hi,

I have created two workbooks, one workbook contains a set of dropdown lists, another workbook contains the data.
I m trying to bind the data from WB2 to dropdown in WB1 using VBScript.
The problem is, the dropdown is not showing the data, instead, it is showing empty rows inside..
Here is my code:

 Private Sub Worksheet_Change(ByVal Target As Range)
   Dim wbSource
   Dim cboTemp As OLEObject
   Dim ws As Worksheet
   Set ws = ActiveSheet
   Set wbSource = Workbooks.Open("..\InputData.xlsx")
   Set cboTemp = ws.OLEObjects("ComboBox4")
   On Error Resume Next
   With cboTemp 
   .Visible = True
   .Left = Target.Left
   .Top = Target.Top
   .Width = Target.Width + 15
   .Height = Target.Height + 5
   .ListFillRange = "'[InputData.xlsx]Availability'!$B$2:$C$9"
   .LinkedCell = Target.Address
  End With
  cboTemp.Activate
  wbSource.Close
End Sub


Please help me in getting the values binded to dropdown list

解决方案

B


2:


C


这篇关于在Excel中进行VBScripting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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