我有我的学校课程,我多次重复隐藏列代码。我需要的是如果你可以帮我缩短代码或者给我一个简单的方法来完成我的工作。如果还有另一种方法,我准备改变一切来完成我的工作。 我希望你能理解我需要的东西。非常感谢并感谢任何帮助。
我无法为我的作品添加附件。这些是我在工作中使用的所有代码。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
If Target.Address(0, 0) <> "B3" Then Exit Sub
Application.ScreenUpdating = False
Columns("b:n").Hidden = True
If Target.Value <> "" Then
For i = 1 To 12
If UCase(MonthName(i)) = UCase(Target.Value) Then
Columns(i + 2).Hidden = False
Exit For
End If
Next
End If
Application.ScreenUpdating = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub ComboBox1_Change()
TextBox1.Value = ComboBox1.Value
End Sub
Private Sub CommandButton1_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
ActiveWorkbook.Save
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton10_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("F:AH,AL:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton11_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("B:E,G:U,X:AM,AP:AP,AR:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton15_Click()
End Sub
Private Sub CommandButton2_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Application.Visible = True
Selection.EntireColumn.Hidden = False
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton4_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Columns("J:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton5_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Columns("F:F").Select
Range("F:K,O:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton6_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("F:P,T:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton7_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("B:E,G:U,Y:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton8_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("F:X,AB:SA").Select
Range("AB1").Activate
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub CommandButton9_Click()
With Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
Columns("a:sb").Select
Selection.EntireColumn.Hidden = False
Range("F:AC,AG:SA").Select
Selection.EntireColumn.Hidden = True
Application.Visible = True
Me.Hide
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With
End Sub
Private Sub Label3_Click()
End Sub
Private Sub MultiPage1_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.Visible = True
Selection.EntireColumn.Hidden = False
Me.Hide
End Sub