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中文網其他相關文章!