VBA Excel控制另一个工作簿上的单元格 [英] VBA Excel taking control of the cells on the another workbook

查看:87
本文介绍了VBA Excel控制另一个工作簿上的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将外部Excel文件上的单元格与活动工作簿中的单元格链接.

我在这里发现了一些不错的东西:

解决方案

  Sub Splicing()昏暗的VariableX作为字符串昏暗的新书作为工作簿VariableX = ActiveWorkbook.Sheets("Frontsheet").Range("D10").Value路径= ActiveWorkbook.Path&"\ Splicing Template_V1.0.xlsx"设置newbook = Workbooks.Open(Path)newbook.sheets("Frontsheet").Cells(4,10).Value = VariableX'不确定这是否是正确的工作表名称结束子 

I would like to link the cells on the external Excel file with the cells from my active workbook.

I found something quite good here:

VBA change value in another workbook

and tried to combine this code with mine:

 Sub Splicing()
 Dim VariableX As Long
 VariableX = ActiveWorkbook.Sheets("Frontsheet").Range("D10").Value
 Path = ActiveWorkbook.Path & "\Splicing Template_V1.0.xlsx"
 Workbooks.Open (Path)
 Worksheets("Frontsheet").Cells(4, 10).Value = VariableX

 End Sub

The debugger says: Type mismatch

Is there any way to link these cells between two separate workbooks?

解决方案

Sub Splicing()
 Dim VariableX As string
 Dim newbook as workbook
 VariableX = ActiveWorkbook.Sheets("Frontsheet").Range("D10").Value
 Path = ActiveWorkbook.Path & "\Splicing Template_V1.0.xlsx"
 set newbook = Workbooks.Open(Path)
 newbook.sheets("Frontsheet").Cells(4, 10).Value = VariableX 'Not sure if this is the right worksheet name

 End Sub

这篇关于VBA Excel控制另一个工作簿上的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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