Multiple VBA codes - Only the one works

Hinklin

New Member
Joined
Jul 19, 2018
Messages
5
Hi there. I am working on a task list at work for multiple teams and sites. I have written a vba for hiding columns depending on the team name. On a separate spreadsheet, I have a code that changes the font name of a cell to Wingdings to allow for a tick to be shown when a task is completed (insisted upon by the finance manager).

However, when I try and use both codes separately, only the code for hiding columns works. Can you give me some tips?

Thanks,
Tom

Code:
Sub Worksheet_Calculate()
Dim theRange As Range, cell As Range
Set theRange = Range("K6:BL158")
For Each cell In theRange
Select Case cell
    Case "ü":
      cell.Font.Name = "Wingdings"
    Case Else:
      cell.Font.Name = "Calibri"
  End Select
Next
End Sub

Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B2")) Is Nothing Then
    Application.EnableEvents = False
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name1" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:AA").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("AH:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name2" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:AP").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("AY:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name3" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:BH").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name4" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("U:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name5" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:BK").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name6" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:AX").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("BI:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name7" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:AG").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("AQ:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Name8" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
            Application.Columns("K:T").Select
            Application.Selection.EntireColumn.Hidden = True
            Application.Columns("AB:BL").Select
            Application.Selection.EntireColumn.Hidden = True
        End If
        If Target.Column = 2 And Target.Row = 2 And Target.Value = "Show All" Then
            Application.Columns("K:BL").Select
            Application.Selection.EntireColumn.Hidden = False
        End If
            ActiveSheet.Range("F4").Select
    End If
    Application.EnableEvents = True
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
The code for changing the font seems fine. However, i'd expect that the Worksheet is NOT calculating. Do you have any formulae on that sheet at all?
 
Upvote 0
Hi James. There was no forumula on that sheet. Just added a count formula at the bottom and now the coding works :) thank you for pointing me in the right direction. Tom
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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
Back
Top