Sub not firing after Call

Status
Not open for further replies.

Gideon du Toit

New Member
Joined
May 22, 2023
Messages
29
Office Version
  1. 2010
Platform
  1. Windows
I am brand new here and have posted a similar thread but I suspect I did not do it correctly, and have no idea how to edit it. But here goes...

I have a large piece of code in a private sub inside a form module, that calls another sub in that same module. When I step through the code, it reads the call statement (Call Get_Consult) but then just moves on to the next statement without executing the code inside the Get_Consult sub.

I have placed a "stop" at the start of the Get_Consult sub but it also never gets read. I have placed a breakpoint right on "Private Sub Get_Consult()" and that breakpoint never gets reached. Why would VBA just choose to ignore my code?

I have no "On Error Resume Next" statement in either of the subs, so that can be ruled out. Please I need assistance as this is the final phase of this project and there is no way for me to repay the $$$ that my client has already paid me. I am posting the call with the code preceding and following it, as well as the entire Get_Consult sub hereunder...

VBA Code:
            For X = 4 To intLastWBS 
            
                If CStr(lstClients.List(iClient)) = CStr(Sheet2.Range("B" & X).Value) Then
                
                            Call Get_Consult
                
                        With Sheet16
                
                            .Range("E16").Value = Format(Date, "Long Date")

and the sub that doesn't run...

VBA Code:
Private Sub Get_Consult() ' Lookup Selected Consultant Details

Dim iiFindSumConsult As Integer
Dim iListboxCount As Integer
Dim iConsultContactDetails As Integer
Dim LastCell As Range
Dim LastCellColRef As Long
Dim intLastWBS As Integer

For iListboxCount = 0 To lstClients.ListCount - 1

If lstClients.Selected(iListboxCount) Then

    For iiFindSumConsult = 15 To 295 Step 45

        If CStr(Sheet6.Range("F" & iiFindSumConsult).Value) = CStr(lstClients.List(iListboxCount)) Then
        
            intCompanyCounter = Sheet6.Range("F" & iiFindSumConsult).Row
            
                LastCellColRef = 7  'Column number to look in when finding last cell

                Set LastCell = Sheet14.Cells(Rows.Count, LastCellColRef).End(xlUp).Offset(1, 0)

                intLastWBS = CInt(LastCell.Row) - 1 
                
                            With Sheet16
            
                            .Range("E13").Value = Sheet6.Range("F" & (intCompanyCounter + 25)) 'Client Rep/Consultant
                            
                                For iConsultContactDetails = 5 To intLastWBS
                                
                                    If Sheet14.Range("G" & iConsultContactDetails).Value = .Range("E13").Value Then
                                                                
                                        .Range("E14").Value = Sheet14.Range("H" & iConsultContactDetails).Value 
                                        .Range("E15").Value = Sheet14.Range("I" & iConsultContactDetails).Value 
                                        Exit Sub
                                        
                                    End If
                                
                                Next iConsultContactDetails

                            End With
        End If
    
    Next iiFindSumConsult
End If

Next iListboxCount

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Duplicate to: Simple Sub Procedure Call not running

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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