我的代码看起来像这样:
malloc
由于工作表名称总是不同,我想删除特定名称,即" 10月6日"并指向此处的最后一个工作表。任何人都可以帮我解决这个问题吗?
感谢您的提前帮助
答案 0 :(得分:1)
您可以使用
轻松选择工作簿中的最后一个工作表Workbooks("Name of your Workbook").Worksheets(Worksheets.Count)
例如
With Workbooks("Book1.xlsm").Worksheets(Worksheets.Count)
'Do whatever you want
End With
我相信您在代码中尝试做的事情就像这样做
With ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
'Do whatever you want
End With
感谢@ YowE3K和@ChrisNeilsen在评论中的贡献
答案 1 :(得分:0)
要访问工作簿的最后一张,请使用以下命令:
Worksheets(Worksheets.Count).Select
试试这个:
Dim Current As Worksheet
' Loop through all of the worksheets in the active workbook.
For Each Current In Worksheets
If Current.Name = "6th Oct" Then Current.Delete
Next
With Worksheets(Worksheets.Count)
With .Range(.Cells(3, "Q"), .Cells(.Rows.Count, "P").End(xlUp).Offset(0, 1))
.Formula = "=IF(OR(J3=""Pending"",J3=""Assigned""),""Pending"",IF(AND(J3=""Closed"",E3=M3),""Passed"",""Failed""))"
End With
End With
Range("Q2").Value = "Test"