Gideon du Toit
New Member
- Joined
- May 22, 2023
- Messages
- 29
- Office Version
- 2010
- Platform
- 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...
and the sub that doesn't run...
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