Column format based on cell value

MrHuge

Board Regular
Joined
Jun 23, 2005
Messages
219
I have the current vb which works great.
Code:
'------------------------------------------------------
'- WORKSHEET CHECKBOX ALTERNATIVE
'- ADDS OR REMOVES TICK IN A CELL. Font = Wingdings.
'------------------------------------------------------
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, _
        Cancel As Boolean)
    Dim MyTick As String
    Dim MyUnTick As String
    MyTick = Chr(254)
    MyUnTick = Chr(111)
    TopRow = 4
    BottomRow = 65536
    '-
    If (ActiveCell.Column = 5 Or (ActiveCell.Column > 6 And ActiveCell.Column < 13) Or (ActiveCell.Column > 17 And ActiveCell.Column < 38) Or ActiveCell.Column = 39 Or ActiveCell.Column = 41 Or ActiveCell.Column = 43 Or ActiveCell.Column = 45 Or (ActiveCell.Column > 46 And ActiveCell.Column < 51)) _
        And ActiveCell.Row >= TopRow _
        And ActiveCell.Row <= BottomRow Then
        If ActiveCell = MyUnTick Then
            ActiveCell.Font.Name = "Wingdings"
            ActiveCell.Font.Size = 12
            ActiveCell.Font.ColorIndex = 3
            ActiveCell.Value = MyTick
        Else
            ActiveCell.Font.Name = "Wingdings"
            ActiveCell.Font.Size = 12
            ActiveCell.Font.ColorIndex = 1
            ActiveCell.Value = MyUnTick
       End If
        ActiveCell.Offset(1, 0).Select
    Else
    End If
End Sub
'-------------------------------------------------------------------------
I would like to change this, so that instead of naming the columns to be used in VB, I would like it to look at Row 1 and if it is equal to 1 then use this script.
ie in Row1 Column 5 i have a "1" value in the cell, then all cells in column 5 use the tick box vb.
I believe i could use an intersect command, but i am not sure on how to do it.

Any help would be appreciated.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,887
Hi

Please try

If Cells(1, ActiveCell.Column)=1

Hope this helps
PGC

P. S. I prefer to use Target. It keeps more focused on the event.
 

Forum statistics

Threads
1,176,197
Messages
5,901,857
Members
434,924
Latest member
husamco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top