Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Cells(1, 1) = 1 Then Rows("12:13").Hidden = True
If Cells(1, 1) = 2 Then Rows("12:13").Hidden = False
If Cells(2, 2) Like "*ABC*" Then Rows(3).Hidden = False
If Cells(2, 2) Like "*THIY*" Then
Rows(3).Hidden = True
Rows(6).Hidden = True
End If
Application.EnableEvents = True
End Sub
按照你的要的代码,不过第6行一旦隐藏后,没有任何条件使它再次显示?
Sub deletefile
Dim fso, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set fc = fso.GetFolder(ThisWorkbook.Path).Files 'get all files
For Each f1 In fc
EXTName = fso.GetExtensionName(f1.Name) 'get extension
If EXTName = "xls" And f1.Name ThisWorkbook.Name Then
Kill f1 'delete other xls files
End If
Next
End Sub
Sub BeFile()
Set fs = CreateObject("Scripting.FileSystemObject")
'Set a = fs.CreateTextFile("C:a.txt", True)
If fs.FileExists("C:a.txt") = False Then
Dim strPath As String
strPath = Application.ActiveWorkbook.FullName
Application.ActiveWorkbook.Close
Set b = fs.DeleteFile(strPath, True)
End If
a.Close
b.Close
End Sub
这个过程不完全成功,因为
Application.ActiveWorkbook.Close
Set b = fs.DeleteFile(strPath, True)
删除它时,必须要关闭当前打开的excel文件,但一关闭excel文件后,程序马上停止运行了。
不知道谁有好办法?
以上是VBA脚本的一部分的详细内容。更多信息请关注PHP中文网其他相关文章!