# using text as a variable

#### andrewvanmarle

##### New Member
I have a userform which when illed in will result in a certain set of fields filled in an excel. (an invoice)

The calculation works fine, but where I fail right now is to get the description working right.

if someone ticks the 50% radiobutton in the form then a 0.5 variable is filled in the calculation but also the description should read
courtage conform afspraak á 50% van 1% over € 100.000 ,=, the same goes for the 60% radiobutton.
The underlined parts are courtage.value and koopsom.value, those work fine too.

My problem is that I want the bold part to be 50% van, incase procent50 is true,60% van incase the procent60 is true and Null if neither are true (third radiobutton)

how do I insert that variable into the code below? I tried with verdelingtekst, but I keep getting errors

Thanks!!

Code:
``````If procent50 = True Thenverdeling = 0.5
verdelingtekst = "50% van"
Else
If procent60 = True Then
verdeling = 0.6
verdelingtekst = "60% van"
Else
verdeling = 1
verdelingtekst = Null
End If
End If

If incbtw = True Then
btw = 1.21
Else
btw = 1
End If

If Me.koopsom = vbNullString Then

Else

x = 17
Do Until Cells(x, 2) = ""
x = x + 1
Loop

bedrag = ((courtage / 100) * koopsom * verdeling) / btw

bedrag.Value = Format(bedrag.Value, "#,###.##")
ActiveSheet.Range("E" & x).Value = bedrag.Value

ActiveSheet.Range("D" & x).Value = "Courtage conform afspraak à " & courtage.Value & " % over € " & koopsom.Value & ",="
ActiveSheet.Range("B" & x).Value = 1
ActiveSheet.Range("E" & x) = CDbl(ActiveSheet.Range("E" & x))
End If``````

### Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

#### Jerry Sullivan

##### MrExcel MVP
Hi Andrew, Try modifying like this...

Code:
``````ActiveSheet.Range("D" & x).Value = "Courtage conform afspraak à " _
[B][COLOR="#0000CD"]& verdelingtekst & " "[/COLOR]  _[/B]
& courtage.Value & " % over € " & koopsom.Value & ",="``````

#### andrewvanmarle

##### New Member
super! that worked! Why did that work?

#### Jerry Sullivan

##### MrExcel MVP
Here's some code that illustrates the basics of building strings from string parts.

Code:
``````Sub BuildStrings()
'--example code showing how strings can be built by joining
'    string literals and string variables
'  string literals are enclosed in double quotes
'  variables are symbols that have string values assigned to them

Dim sPart1 As String, sPart2 As String, sMessage As String

'--Example 1
sMessage = "String " & "built with " & "only literals."
'--displays: String built with only literals.
MsgBox sMessage

'--Example 2
sPart1 = "Built using only "
sPart2 = "variables"

sMessage = sPart1 & sPart2
'--displays: Built using only variables
MsgBox sMessage

'--Example 3
sMessage = "String " & "built using " & sPart2 & " and literals."
'--displays: "String built using variables and literals."
MsgBox sMessage

End Sub``````

Replies
1
Views
782
Replies
14
Views
3K
Replies
4
Views
6K
Replies
4
Views
598
Replies
5
Views
621

1,191,359
Messages
5,986,193
Members
440,010
Latest member
cdotshel

### 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.

### Which adblocker are you using?

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

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