this is going to be the best small tool for excel users.
here is the video. and here is the code of Spin Button.
Private Const DefaltWidth As Integer = 9
Dim TargetSheetName As String
Dim TargetSheet As Worksheet
Dim FirstColNo As Integer
Dim LastColNo As Integer
Dim I As Integer
Private Sub SpinButton1_SpinDown()
Application.ScreenUpdating = False
'Assigning Values to the Variables
TargetSheetName = "Sheet1"
Set TargetSheet = Application.ThisWorkbook.Sheets(TargetSheetName)
FirstColNo = TargetSheet.Range("A7").Value
LastColNo = TargetSheet.Range("A9").Value
If TargetSheet.Range("A7").Value = Empty Or TargetSheet.Range("A9").Value = Empty Then
MsgBox "Please Set The Column Range Limits Before You Proceed", vbCritical, "Kamal Bharakhda"
Exit Sub
End If
'Code For Unhiding Columns One By One from Limit One to Last Column
For I = LastColNo To FirstColNo Step -1
If TargetSheet.Columns(I).ColumnWidth = 0 Then
TargetSheet.Columns(I).ColumnWidth = DefaltWidth
Exit For 'This is most important point if you want to show columns one by one.
End If
Next I
Set TargetSheet = Nothing
Application.ScreenUpdating = True
End Sub
Private Sub SpinButton1_SpinUp()
Application.ScreenUpdating = False
'Assigning Values to the Variables
TargetSheetName = "Sheet1"
Set TargetSheet = Application.ThisWorkbook.Sheets(TargetSheetName)
FirstColNo = TargetSheet.Range("A7").Value
LastColNo = TargetSheet.Range("A9").Value
If TargetSheet.Range("A7").Value = Empty Or TargetSheet.Range("A9").Value = Empty Then
MsgBox "Please Set The Column Range Limits Before You Proceed", vbCritical, "Kamal Bharakhda"
Exit Sub
End If
'Code For Hiding Columns One By One from Limit One to Last Column
For I = FirstColNo To LastColNo Step 1
If TargetSheet.Columns(I).ColumnWidth > 0 Then
TargetSheet.Columns(I).ColumnWidth = 0
Exit For 'This is most important point if you want to hide columns one by one.
End If
Next I
Set TargetSheet = Nothing
Application.ScreenUpdating = True
End Sub
No comments:
Post a Comment