Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1070491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:34:25+00:00 2026-05-16T20:34:25+00:00

I made a Sheet which I have now converted to a UserForm but the

  • 0

I made a Sheet which I have now converted to a UserForm but the VB code I was using no longer works, I will copy the old code used and the new one which keeps telling me “Debtor not found”, any help would be Appreciated.

Old Code:

Sub Buy_Click()

    Name = Worksheets("Purchase").Range("G19").Value
    Amount = CSng(Worksheets("Purchase").Range("I19").Value)
    Balance = CSng(Worksheets("Purchase").Range("J19").Value)

    If Name = "" Then
        MsgBox "Select Debtor"
        Exit Sub
    End If



    DebtorRow = 1
    Do
        TempName = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
        If TempName = Name Then
            DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
            Exit Do
        End If
        DebtorRow = DebtorRow + 1
    Loop Until TempName = ""

    If TempName = "" Then
        MsgBox "Debtor not found"
        Exit Sub
    End If


    Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance - Amount

MsgBox "You have just Purchased " & Range("H19") & " For $" & Range("I19") & vbCrLf & "Your Account Balance is now: " & Range("J19")

    Application.Goto Reference:="Purchase_Debtor"
    Selection.ClearContents

    Application.Goto Reference:="Purchase_Quantity"
    Selection.ClearContents

    Sheets("Menu").Select

End Sub

New Code:

Private Sub cmdBuy_Purchase_Click()

    Purchase_Select_Debtor.Value = Name
        Purchase_Select_Price.Value = Amount
    Purchase_Select_Balance.Value = Balance

    If Name = "" Then
        MsgBox "Select Debtor"
        Exit Sub
    End If

    DebtorRow = 1
    Do
        TempName = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
        If TempName = Name Then
            DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
            Exit Do
        End If
        DebtorRow = DebtorRow + 1
    Loop Until TempName = ""

    If TempName = "" Then
        MsgBox "Debtor not found"
        Exit Sub
    End If


    Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance - Amount

MsgBox "You have just Purchased " & Amount & " For $" & Amount & vbCrLf & "Your Account Balance is now: " & Balance

End Sub

And another Code I’ve used for a different UserForm with the same issue;

Old Code:

Sub Pay_Click()

    Name = Worksheets("pay_balance").Range("F18").Value
    Amount = CSng(Worksheets("pay_balance").Range("G18").Value)

    If Name = "" Then
        MsgBox "Select Debtor"
        Exit Sub
    End If

    DebtorRow = 1
    Do
        TempName = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
        If TempName = Name Then
            DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
            Exit Do
        End If
        DebtorRow = DebtorRow + 1
    Loop Until TempName = ""

    If TempName = "" Then
        MsgBox "Debtor not found"
        Exit Sub
    End If


    Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance + Amount

    MsgBox "You have just Credited $" & Range("G18") & vbCrLf & "Your Account Balance is now: " & Range("H18")

    Application.Goto Reference:="Creditbox"
    Selection.ClearContents

    Application.Goto Reference:="Balance_Debtor"
    Selection.ClearContents

    Sheets("Menu").Select

End Sub

New Code:

Private Sub cmdPay_Balance_Click()

Pay_Balance_Balance.Value = Name
Pay_Balance_Credit.Value = Amount

    If Name = "" Then
        MsgBox "Select Debtor"
        Exit Sub
    End If

    DebtorRow = 1
    Do
        TempName = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
        If TempName = Name Then
            DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
            Exit Do
        End If
        DebtorRow = DebtorRow + 1
    Loop Until TempName = ""

    If TempName = "" Then
        MsgBox "Debtor not found"
        Exit Sub
    End If


    Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance + Amount

    MsgBox "You have just Credited $" & Amount & vbCrLf & "Your Account Balance is now: " & Name

End Sub
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:34:26+00:00Added an answer on May 16, 2026 at 8:34 pm
    Private Sub cmdBuy_Purchase_Click()
    
        Debtor = Purchase_Select_Debtor.Value
        Amount = CSng(txtPrice.Value)
        Balance = CSng(txtBalance.Value)
    
        If Debtor = "" Then
            MsgBox "Select Debtor"
            Exit Sub
        End If
    
        DebtorRow = 1
        Do
            TempDebtor = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
            If TempDebtor = Debtor Then
                DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
                Exit Do
            End If
            DebtorRow = DebtorRow + 1
        Loop Until TempDebtor = ""
    
        If TempDebtor = "" Then
            MsgBox "Debtor not found"
            Exit Sub
        End If
    
        Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance - Amount
    
        Balance = Application.VLookup(Purchase_Select_Debtor.Value, Sheets("Debtor_list").Range("A2:B13"), 2, 0)
    
        MsgBox "You have just Purchased " & Purchase_Select_Quantity.Value & " For $" & Amount & vbCrLf & "Your Account Balance is now: " & Balance
    
        Unload FrmPurchase
    
    End Sub
    

    &

    Sub cmdPay_Balance_Click()
    
        Debtor = Pay_Balance_Select_Debtor.Value
        Amount = CSng(txtCredit.Value)
    
        If Debtor = "" Then
            MsgBox "Select Debtor"
            Exit Sub
        End If
    
        DebtorRow = 1
        Do
            TempDebtor = Worksheets("Debtor_list").Range("A" & DebtorRow).Value
            If TempDebtor = Debtor Then
                DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value)
                Exit Do
            End If
            DebtorRow = DebtorRow + 1
        Loop Until TempDebtor = ""
    
        If TempDebtor = "" Then
            MsgBox "Debtor not found"
            Exit Sub
        End If
    
    
        Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance + Amount
    
        txtBalance.Value = Application.VLookup(Pay_Balance_Select_Debtor.Value, Sheets("Debtor_list").Range("A2:B13"), 2, 0)
    
        MsgBox "You have just Credited $" & Amount & vbCrLf & "Your Account Balance is now: " & txtBalance
    
        Unload frmPay_Balance
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made an excel sheet which is generated by Java. The cells can
I have some Dynamic named Ranges in my sheet.Ive made them dynamic using the
I made a Web service in which I have a function to count some
I made a UITableViewCell and I have 20 rows in that table in which
I used the code described here to update an excel sheet using c#. The
I have a script which is reading values from an excel sheet and inserting
I have made a div and I have given it position: fixed using this
I have a JSP form which is made of <input type=file/> tag alone for
The first part is now working [ I have the following which just seems
Made this nice little loop for hiding and showing div's, works as a charm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.