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
According to the code you want, but once line 6 is hidden, there is no condition for it to be displayed again?
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
This process is not completely successful because
Application.ActiveWorkbook.Close
Set b = fs.DeleteFile(strPath, True)
When deleting it, you must close the currently open excel file, but as soon as you close the excel file, the program stops running.
I don’t know if anyone has a good idea?
The above is the detailed content of Part of VBA script. For more information, please follow other related articles on the PHP Chinese website!