excel - 基于单元格值的工作簿名称
问题描述
所以,我有下面的代码,即隐藏所有列中包含 1 的行。每次必须更改文件名时,我都必须更改代码。
Workbooks("New R.M.S. Holiday Planner.xlsm").Worksheets("Planner").Activate
而不是New RMS Holiday Planner.xlsm,我想将它指向单元格 A1,我将在其中获得文件名。
可能这很愚蠢,但我无法解决。谢谢你的帮助。
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Workbooks("New R.M.S. Holiday Planner.xlsm").Worksheets("Planner").Activate
With Sheets("Planner")
Rows("11:1897").EntireRow.Hidden = False
Application.ScreenUpdating = False
For Each Cell In Range("BE10:BE1897")
If Cell.Value = 1 Then Cell.EntireRow.RowHeight = 0.00001
Next Cell
Range("Y2:AF2").Select
ActiveCell.FormulaR1C1 = "S&S Days"
Range("A1").Select
' .Protect Password:="folder"
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End With
Else
If CheckBox1.Value = False Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Workbooks("New R.M.S. Holiday Planner.xlsm").Worksheets("Planner").Activate
With Sheets("Planner")
For Each Cell In Range("BE10:BE1897")
If Cell.Value = 1 Then Cell.EntireRow.RowHeight = 12.75
Next Cell
Range("Y2:AF2").Select
ActiveCell.FormulaR1C1 = "All"
Range("A1").Select
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End With
End If
End If
End Sub
解决方案
推荐阅读
- sql - 在结果集中为输入字符串中的每个换行符创建一个新行
- gitlab - 如何在 gitlab 中的作业之间移动 jar 文件?
- python - 如何格式化 Python 中标签(或其他小部件)中的文本位置?
- javascript - 为什么这些 div 的对齐方式都不同?
- powershell - Azure DSC 将 Blob 上传到 Azure VM
- c# - Windows 2004 更新后无法以其他用户身份运行 EXCEL.EXE
- apache-spark - pyspark中的条件爆炸
- java - 在 mongo-java-driver 3.12 的 MongoCollection.deleteMany 中使用 WriteConcern
- python - Python:使用 cons、car 和 cdr 进行函数式编程
- spring-integration-dsl - 具有事务控制的 Spring 集成 DSL JMS 和 CrudRepository