|
-
Oct 26th, 2010, 05:20 AM
#1
Thread Starter
Addicted Member
[RESOLVED] E-mail address problem
I am trying to run a (rough) check on a column in an excel sheet to see if the user has entered valid e-mail addresses. In the organisation for which I work the format for an e-mail address is [email protected] Where there is more than one person with the same first and last names there is also a number after the firstname.lastname and before the @ symbol. As a general rule, if your e-mail address is [email protected] then your log-on to the restricted employee network is firstname.lastname (My log-on is one of the exceptions to this rule!) Therefore I think the most likely mistake users would make when filling out the spreadsheet is to leave off the “@myorganisation.gov.au”. To check for this, I want to use something like
Code:
For j = 1 to max_no
email_address = Cells(j + 1, 9)
If InStr(email_address, “@”) = 0 then
MsgBox(“This probably isn’t a valid e-mail address. Please check it.”
Cells(j + 1,9).Select
Cells(j + 1,9).Activate
GoTo Stop_Check
End if
Next j
Stop_Check:
The problem I have is that VBA doesn’t appear to recognise the @ symbol. How do I get around this?
-
Oct 26th, 2010, 06:21 AM
#2
Re: E-mail address problem
there is no problem with instr and @ in vba
works fine
there must be some other issue
edit: if you locale language can require @ to be escaped, try using the chr value
if instr(somestring, chr(64)) = 0 then
Last edited by westconn1; Oct 26th, 2010 at 03:22 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 26th, 2010, 03:20 PM
#3
Re: E-mail address problem
What is the value of email_address at the time of error if you are getting any error?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 27th, 2010, 05:48 AM
#4
Thread Starter
Addicted Member
Re: E-mail address problem
The e-mail address is something like: [email protected] (with a few changes to protect people's privacy - but there are no other sorts of characters in the e-mail address). Basically, "Mr Abbott" is the first person on the list.
If you're wondering why I'm not searching for "myorganisation.gov.au" this is to allow for one or two cases where people may need to use an address other than their usual work address.
-
Oct 27th, 2010, 05:50 AM
#5
Thread Starter
Addicted Member
Re: E-mail address problem
I haven't had a chance to have another look at my code today - I got caught up doing other things at work.
-
Oct 27th, 2010, 06:41 AM
#6
Thread Starter
Addicted Member
Re: E-mail address problem
I've just tried the routine at home where it works fine, I think Pete must be right about there being some other problem with the code. (It's in a nested loop, so I've probably made a logic error with the work version - even the nested version works fine at home.) So this one is resolved. Thanks everyone, I appreciate your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|