vba vlookup variable

bensonsearch

Well-known Member
Joined
May 26, 2011
Messages
844
Hi All,

I have a vlookup that looks at customers and sees if the email address is in the data, this works fine until i start adding them with ; at the end.

I tried changing the variable (call it asd) that the vlookup sets to, to have asd = asd + ";" also tried asd = asd & ";" none work

i have the asd set to variant since string makes an error, is there a way to make this work or a different data type i can use?

let me know if i make no sense :)
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
It might make more sense if we saw the code.:)
 
Upvote 0
Fair enough :)

Code:
vlook = TextBox1.Text 'textbox1.text is the customer name
 
value = Application.VLookup(vlook, Worksheets("Sheet1").Range("A2:L" & count), 7, False)
'row 7 is the email address with ; at the end for mass emailing
If IsError(value) Then'code to add customer (works fine)
else
'code if a match is found
end if

the error is a match will never be found as the emails are stored with ; at end but the textbox with the new details will not. hope this helps more, can paste full code if really needed
 
Upvote 0
vlook is the name but i have tried at the end of the vlookup and for value (value is the email vlook customer name)
 
Upvote 0
Can you explain what you mean by adding ';' at the end if them?

If you mean the emails in Column A then you should just be able to add ';' at the end of the the variable vlook.
 
Upvote 0
Can you explain what you mean by adding ';' at the end if them?

If you mean the emails in Column A then you should just be able to add ';' at the end of the the variable vlook.


the emails are stored with ;
eg email@email.com;

i tried adding it to the end but it didnt work at first as i was vlookuping the name and returning the email

I have now changed it to be looking up email and it works (email was in coloum 7 now in coloum1)
 
Upvote 0
Sorry you've lost me.

The name column was unchanged but the lookup stopped working?

That shouldn't really happen.

By the way, have you considered using a listbox or combobox instead if a textbox?

Then you wouldn't need the lookup.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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