简体   繁体   English

VBA 使用 InputBox 定义工作表的名称并将其存储在变量中

[英]VBA use InputBox to define name of sheet and store it in variable

I am searching for hours now and no solution, I am trying to define a variable from InputBox, to use it as Sheet name and copy value from range A1.我现在搜索了几个小时但没有解决方案,我试图从 InputBox 定义一个变量,将其用作工作表名称并从范围 A1 复制值。

the sheet name should be the one from Inputbox..工作表名称应该是 Inputbox 中的那个..

Dim wss As String
wss = InputBox("Sheet name")
Sheets("EBS Posting template").Range("A1") = Wss.Range("A1")

This isn't working either这也不起作用

Sheets("EBS Posting template").Range("A1") = Sheets(Wss).Range("A1")

this works for me.这对我有用。 I think the issue is that you missed the value at the range:我认为问题在于您错过了该范围内的

Sub Makro1()
Dim wss As String
wss = InputBox("Sheet name")
Sheets("Tabelle1").Range("A1").Value = Sheets(wss).Range("b1")

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM