vba 将单元格内容设置为工作表名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19233710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:49:52 来源:igfitidea点击:
Set cell contents to sheet name
提问by Ship72
Simple question for you experts out there.
对您那里的专家的简单问题。
Trying to figure out how to have cell A1 = sheetname.
试图弄清楚如何让单元格 A1 = sheetname。
I tried the following but got a compile error
我尝试了以下但编译错误
y = Sheetname()
Range(A1) = y
回答by sam092
ActiveSheet.Range("A1") = ActiveSheet.Name
ActiveSheet.Range("A1") = ActiveSheet.Name
If you want it for every sheet, then
如果你想要每张纸,那么
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Range("A1") = ws.Name
Next