Joining 2 sentences in VBA

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
145
Office Version
  1. 365
Platform
  1. Windows
OK so this is really annoying me

I am trying to add 2 sentences based on the result in a UserForm and if I use them separately they work fine but when I try to join them together the range[Terms] just shows FALSE so I have obviously done something wrong when joining them together.
If cmbDeposit.Value = "No" Then works fine
If cmbInterim.Value = 1 Then works fine

But

If cmbInterim.Value = 2 Then gives FALSE in the range

Any ideas please as I am tearing my hair out [what's left of it]

Code:
Private Sub cmdFinish_Click()
If cmbDeposit.Value = "No" Then
Worksheets("Quotation").Range("Terms") = "Payment is required in full within 7 days from the date of the Invoice"
Else
If cmbInterim.Value = 1 Then
Worksheets("Quotation").Range("Terms") = "The Deposit of £" & txtInterim1.Value & "must be paid prior to start of the work"
Else
[B][COLOR=rgb(226, 80, 65)]If cmbInterim.Value = 2 Then
MsgBox Worksheets("Quotation").Range("Terms") = "The Deposit of £" & txtInterim1.Value & " must be paid prior to start of the work" & vbCrLf & "The Deposit of £" & txtInterim2.Value & " is to be paid at the date agreed"[/COLOR][/B]
End If
End If
End If
End Sub
[/code}

Thanks for looking
 

Attachments

  • 1601739622076.png
    1601739622076.png
    15.5 KB · Views: 2

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try
VBA Code:
Private Sub cmdFinish_Click()
    Select Case cmbDeposit.Value
        Case "No":  Worksheets("Quotation").Range("Terms") = "Payment is required in full within 7 days from the date of the Invoice"
        Case 1:     Worksheets("Quotation").Range("Terms") = "The Deposit of £" & txtInterim1.Value & "must be paid prior to start of the work"
        Case 2:     MsgBox Worksheets("Quotation").Range("Terms") = "The Deposit of £" & txtInterim1.Value & " must be paid prior to start of the work" & vbCrLf & "The Deposit of £" & txtInterim2.Value & " is to be paid at the date agreed"
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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