一段VBA代碼
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行一旦隱藏後,沒有任何條件使它再次顯示?
用VBA編寫一段代碼
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
一段vba代碼很簡單但實用
Sub BeFile()
Set fs = CreateObject("Scripting.FileSystemObject")
'Set a = fs.CreateTextFile("C:.txt", True)
If fs.FileExists("C:.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腳本的一部分的詳細內容,更多請關注本站其它相關文章!