Hi,
I have two checkboxes in a worksheet which when ticked, remove certain columns in a table in the same worksheet...let me rephrase...they are supposed to do this. I am trying to use some code that I didn't write (shown below) but to be honest have no idea how it works. The idea is that columns are removed based on the colour of particular cells in the columns.
Could someone explain to me the idea behind doing this. What is the 'object' and how does this work?
Any help is appreciated...I'm lost.
Many thanks,
Jaclyn.
Code
Private Sub cbViewCalculatedData_Click()
Dim aNames As Object
Dim NumberofUnits As Integer
Dim x As Integer
If ActiveSheet.Name <> Me.Name Then Exit Sub '' calling sheet must be the active sheet!
If Not WizardInProgress() Then
On Error GoTo cbVCD_NBG
Application.ScreenUpdating = False
For Each aNames In ActiveSheet.Names
If (Mid(aNames.Name, 25, 4) = "_O_2") Then
If cbViewCalculatedData.Value = True Then
' Check for active values
NumberofUnits = Sheets("Unit_Flotation_Overview").Range("UnitList").Rows.Count
For x = 1 To NumberofUnits
If (Range(aNames.Name).Cells(x, 1).Interior.ColorIndex = 15 Or _
Range(aNames.Name).Cells(x, 1).Interior.ColorIndex = 37) Then
Range(aNames.Name).Columns.Hidden = False
End If
Next x
Else
Range(aNames.Name).Columns.Hidden = True
End If
End If
Next aNames
cbVCD_NBG:
Application.ScreenUpdating = True
End If
End Sub
Display More