Combine 2 Subs in one event

ChrisCione

Board Regular
Joined
Aug 27, 2008
Messages
92
Office Version
  1. 365
Platform
  1. Windows
How do I combine these two subs into one (On Format event of a report's detail section)?

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtReferralIssuedDate) = 0 Then
    Me.txtUSAJobsCloseDate.Visible = True
    Me.lblREFERRALISSUED.Visible = False

Else
    Me.txtUSAJobsCloseDate.Visible = False
    Me.lblREFERRALISSUED.Visible = True

End If
End Sub

and

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me.txtReferralReturnedDate) = 0 Then
    Me.txtReferralDueDate.Visible = True
    Me.lblRETURNED.Visible = False
    
Else
    Me.txtReferralDueDate.Visible = False
    Me.lblRETURNED.Visible = True
 
End If
End Sub

Many thanks in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Just drop the body of one into the other, i.e.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

'1st block
If Nz(Me.txtReferralIssuedDate) = 0 Then
    Me.txtUSAJobsCloseDate.Visible = True
    Me.lblREFERRALISSUED.Visible = False
Else
    Me.txtUSAJobsCloseDate.Visible = False
    Me.lblREFERRALISSUED.Visible = True
End If

'2nd block
If Nz(Me.txtReferralReturnedDate) = 0 Then
    Me.txtReferralDueDate.Visible = True
    Me.lblRETURNED.Visible = False
Else
    Me.txtReferralDueDate.Visible = False
    Me.lblRETURNED.Visible = True
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,574
Messages
6,160,602
Members
451,657
Latest member
Ang24

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