Isbold Function

rach_oh

New Member
Joined
Aug 2, 2023
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
I have the IsBold function as a module to use a formula in my workbook. Everytime i run another sub, the formula that uses the function throws an error. Is there any work around for this?

IsBold function:

Function IsBold(BoldRange As Range)
IsBold = BoldRange.Font.Bold
Application.Calculation = xlCalculationAutomatic
End Function

Other Subs that run and throw off IsBold function

Private Sub CommandButton1_Click()
LineStart = 6
LineEnd = 217
ColumnNumber = 2
For i = LineStart To LineEnd
If Cells(i, ColumnNumber).Value <> "Yes" Then
Cells(i, ColumnNumber).EntireRow.Hidden = True
Else
Cells(i, ColumnNumber).EntireRow.Hidden = False
End If
Next i
End Sub

Private Sub CommandButton2_Click()
Dim tbl As ListObject
Set tbl = Worksheets("Dynamics Data Load").ListObjects("Table1")
With tbl.DataBodyRange
If .Rows.Count > 1 Then
.Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Rows.Delete
End If
End With
tbl.DataBodyRange.Rows(1).SpecialCells(xlCellTypeConstants).ClearContents
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi and welcome to MrExcel

Add this line to the end of your macros:
VBA Code:
Application.ScreenUpdating = True

Rich (BB code):
Private Sub CommandButton1_Click()
  LineStart = 6
  LineEnd = 217
  ColumnNumber = 2
  For i = LineStart To LineEnd
    If Cells(i, ColumnNumber).Value <> "Yes" Then
      Cells(i, ColumnNumber).EntireRow.Hidden = True
    Else
      Cells(i, ColumnNumber).EntireRow.Hidden = False
    End If
  Next i
  Application.ScreenUpdating = True
End Sub

Rich (BB code):
Private Sub CommandButton2_Click()
Dim tbl As ListObject
Set tbl = Worksheets("Dynamics Data Load").ListObjects("Table1")
With tbl.DataBodyRange
If .Rows.Count > 1 Then
.Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Rows.Delete
End If
End With
tbl.DataBodyRange.Rows(1).SpecialCells(xlCellTypeConstants).ClearContents
Application.ScreenUpdating = True
End Sub


--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Upvote 0
It works better this way:

VBA Code:
Function IsBold(BoldRange As Range)
  Application.Volatile
  IsBold = BoldRange.Font.Bold
End Function


VBA Code:
Private Sub CommandButton1_Click()
  Application.ScreenUpdating = False
  LineStart = 6
  LineEnd = 217
  ColumnNumber = 2
  For i = LineStart To LineEnd
    If Cells(i, ColumnNumber).Value <> "Yes" Then
      Cells(i, ColumnNumber).EntireRow.Hidden = True
    Else
      Cells(i, ColumnNumber).EntireRow.Hidden = False
    End If
  Next i
  Application.ScreenUpdating = True
  Application.Calculate
End Sub

Private Sub CommandButton2_Click()
  Dim tbl As ListObject
 
  Application.ScreenUpdating = False
  Set tbl = Worksheets("Dynamics Data Load").ListObjects("Table1")
  With tbl.DataBodyRange
    If .Rows.Count > 1 Then
      .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count).Rows.Delete
    End If
  End With
  tbl.DataBodyRange.Rows(1).SpecialCells(xlCellTypeConstants).ClearContents
  Application.ScreenUpdating = True
  Application.Calculate
End Sub


--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------
 
Upvote 0
Private Sub ToggleButton4_Click()
Dim rng As Range

Set rng = Range("N:O,U:V,AB:AC,AI:AJ,AP:AQ,AW:AX," & _
"BD:BE,BK:BL,BR:BS,BY:BZ,CF:CG,CM:CN,CT:CU")

With Me.ToggleButton4
rng.EntireColumn.Hidden = .Value
.Caption = IIf(.Value, "Show 2023 Actuals", "Hide 2023 Acutals")
End With
End Sub

Also have this sub, where should the "Application" line be added in the beginning?
 
Upvote 0
At the beginning and at the end:

Rich (BB code):
Private Sub ToggleButton4_Click()
  Dim rng As Range
  
  Application.ScreenUpdating = False
  Set rng = Range("N:O,U:V,AB:AC,AI:AJ,AP:AQ,AW:AX," & _
    "BD:BE,BK:BL,BR:BS,BY:BZ,CF:CG,CM:CN,CT:CU")
  
  With Me.ToggleButton4
    rng.EntireColumn.Hidden = .Value
    .Caption = IIf(.Value, "Show 2023 Actuals", "Hide 2023 Acutals")
  End With
  Application.ScreenUpdating = True
  Application.Calculate
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,843
Members
449,193
Latest member
MikeVol

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