Private Sub Worksheet_Activate()

royca

New Member
Joined
Jan 27, 2011
Messages
44
I am using the following code on a few different sheets for input from an audit. I don't know if it is the best way to collect input but I like it. What I would like to do is reset the column with the wingdings font "o" every time the user changes sheets. I can not quite seem to figure out the right syntax. How do I make Range("C2:C20") all "o" every time I select the sheet?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("C2:C20")) Is Nothing Then
Cancel = True
With Target
.Font.Name = "Wingdings"
.Font.Size = 20
.HorizontalAlignment = xlCenter
End With
If Target.Value = "o" Then
Target.Value = "þ"
Target.Font.ColorIndex = 10
ElseIf Target.Value = "þ" Then
Target.Value = "ý"
Target.Font.ColorIndex = 3
ElseIf Target.Value = "ý" Then
Target.Value = "o"
Target.Font.ColorIndex = 0
Else
Target.Value = "þ"
Target.Font.ColorIndex = 10
End If
End If
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

patel45

Well-known Member
Joined
Jul 15, 2012
Messages
1,953
put in the workbook module
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Set Target = Range("C2:C20")
Cancel = True
With Target
  .Font.Name = "Wingdings"
  .Font.Size = 20
  .HorizontalAlignment = xlCenter
End With
For Each cell In Target
  With cell
    If .Value = "o" Then
      .Value = "þ"
      .Font.ColorIndex = 10
    ElseIf .Value = "þ" Then
      .Value = "ý"
      .Font.ColorIndex = 3
    ElseIf .Value = "ý" Then
      .Value = "o"
      .Font.ColorIndex = 0
    Else
      .Value = "þ"
      .Font.ColorIndex = 10
    End If
  End With
Next
End Sub
 

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
Code:
Private Sub Worksheet_Activate()
Range("C2:C20") = "o"
end sub
or perhaps:
Code:
Private Sub Worksheet_Activate()
With Range("C2:C20")
  .Value = "o"
  .Font.ColorIndex = 0
End With
End Sub
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,371
Messages
5,595,784
Members
414,020
Latest member
Meghdad

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