Hello all,
I have created an Userform with two combo boxes and two textboxes to capture information such as names and farms from a list with the combo boxes and dates and emails with the textboxes in different cells on the same sheet called "Aanbevelingsblad".
What I have tried is to write a code that checks If the textbox for the emails are empty Then pastes a formula that matches the name and farm with the email in a list on another sheet named "Adresse!"; Else it places the email that was entered in the designated cell B8.
When I click the submit button the code does not place the Formula in cell B8 If empty, instead it says False when the textbox is empty. The Else part works well.
<code>
Dim nmRg As Range
Dim plRang As Range
Dim eposRgn As Range
Set dtRng = Sheets("Aanbevelingsblad").Range("H6")
Set nmRg = Sheets("Aanbevelingsblad").Range("B6")
Set plRang = Sheets("Aanbevelingsblad").Range("B7")
Set eposRgn = Sheets("Aanbevelingsblad").Range("B8")
dtRng = Me.txbDatum
nmRg = Me.cmbNm
plRang = Me.cmbPs
'This is the part that does not place the formula in cell B8 when I click submit
If Trim(txbEpos.Value & vbNullString) = vbNullString Then
eposRgn = Me.txbEpos.Text = "=INDEX(Adresse!$C$2:$C$500,MATCH($B6&$B7,INDEX(Adresse!$A$2:$A$500&Adresse!$B$2:$B$500,),0))"
Else
eposRgn = Me.txbEpos
End If
</code>
Can someone please assist me to make the code in red functional?
Regards
I have created an Userform with two combo boxes and two textboxes to capture information such as names and farms from a list with the combo boxes and dates and emails with the textboxes in different cells on the same sheet called "Aanbevelingsblad".
What I have tried is to write a code that checks If the textbox for the emails are empty Then pastes a formula that matches the name and farm with the email in a list on another sheet named "Adresse!"; Else it places the email that was entered in the designated cell B8.
When I click the submit button the code does not place the Formula in cell B8 If empty, instead it says False when the textbox is empty. The Else part works well.
<code>
Dim nmRg As Range
Dim plRang As Range
Dim eposRgn As Range
Set dtRng = Sheets("Aanbevelingsblad").Range("H6")
Set nmRg = Sheets("Aanbevelingsblad").Range("B6")
Set plRang = Sheets("Aanbevelingsblad").Range("B7")
Set eposRgn = Sheets("Aanbevelingsblad").Range("B8")
dtRng = Me.txbDatum
nmRg = Me.cmbNm
plRang = Me.cmbPs
'This is the part that does not place the formula in cell B8 when I click submit
If Trim(txbEpos.Value & vbNullString) = vbNullString Then
eposRgn = Me.txbEpos.Text = "=INDEX(Adresse!$C$2:$C$500,MATCH($B6&$B7,INDEX(Adresse!$A$2:$A$500&Adresse!$B$2:$B$500,),0))"
Else
eposRgn = Me.txbEpos
End If
</code>
Can someone please assist me to make the code in red functional?
Regards