PC Review


Reply
 
 
Sean
Guest
Posts: n/a
 
      10th Feb 2008
Below is the code (ex Ron de Bruin) I am using to populate the CC
field in my auto e-mail file. The issue I am trying to overcome is
sometimes the field where the CC values are held are empty, other
occasions they have a valid address, how could I tweak below to allow
this?

For Each cell In ThisWorkbook.Sheets("Mail") _
.Columns("AI").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
strcc = strcc & cell.Value & ";"
End If
Next
strcc = Left(strcc, Len(strcc) - 1)
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      10th Feb 2008
> strcc = Left(strcc, Len(strcc) - 1)

Try this

If Len(strcc) > 0 Then strcc = Left(strcc, Len(strcc) - 1)




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sean" <(E-Mail Removed)> wrote in message news:477f7c87-628e-47e6-bad6-(E-Mail Removed)...
> Below is the code (ex Ron de Bruin) I am using to populate the CC
> field in my auto e-mail file. The issue I am trying to overcome is
> sometimes the field where the CC values are held are empty, other
> occasions they have a valid address, how could I tweak below to allow
> this?
>
> For Each cell In ThisWorkbook.Sheets("Mail") _
> .Columns("AI").Cells.SpecialCells(xlCellTypeConstants)
> If cell.Value Like "?*@?*.?*" Then
> strcc = strcc & cell.Value & ";"
> End If
> Next
> strcc = Left(strcc, Len(strcc) - 1)

 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      10th Feb 2008
Thanks Ron.

One other small issue, how do I limit the range where it looks for an
address in Column AI, to say AI3:AI5, rather than looking n the whole
column

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      10th Feb 2008
It will only loop through the cells with data in the column

> .Columns("AI").Cells.SpecialCells(xlCellTypeConstants)



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sean" <(E-Mail Removed)> wrote in message news:6e692d7d-4080-4d51-a1d3-(E-Mail Removed)...
> Thanks Ron.
>
> One other small issue, how do I limit the range where it looks for an
> address in Column AI, to say AI3:AI5, rather than looking n the whole
> column
>

 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      10th Feb 2008
The situation I had in mind Ron, is where my TO; CC and BCC addresses
are all in the same column

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      10th Feb 2008
..Range("A3:AI5").Cells.SpecialCells(xlCellTypeConstants)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sean" <(E-Mail Removed)> wrote in message news:c8684d93-4228-47d5-8dcb-(E-Mail Removed)...
> The situation I had in mind Ron, is where my TO; CC and BCC addresses
> are all in the same column
>

 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      10th Feb 2008
Wow Thanks Ron, its a simple as that

 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      11th Feb 2008
Ron I tried If Len(strcc) > 0 Then strcc = Left(strcc, Len(strcc) -
1)

but getting a message 'no cells found' on line

For Each cell In ThisWorkbook.Sheets("Area 1") _
.Range("AI2:AI3").Cells.SpecialCells(xlCellTypeConstants)

Which is correct in that there is no address, but thats were I wish to
have no e-mail address added to my mail (my TO field will always have
an address, so it will be a vaild e-mail, just my CC and BCC feilds
may not always have an address)


 
Reply With Quote
 
Sean
Guest
Posts: n/a
 
      11th Feb 2008
Ron, it maybe relevant but the e-mail addresses in the CC and BCC
feild are formula derived, as like

=IF(AY$10>=1,"(E-Mail Removed)","")

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      11th Feb 2008
Hi Sean

Use this then

On Error Resume Next
For Each cell In ThisWorkbook.Sheets("Mail") _
.Range("A3:AI5").Cells.SpecialCells(xlCellTypeFormulas)

If cell.Value Like "?*@?*.?*" Then
strcc = strcc & cell.Value & ";"
End If
Next
If Len(strcc) > 0 Then strcc = Left(strcc, Len(strcc) - 1)
On Error GoTo 0


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sean" <(E-Mail Removed)> wrote in message news:dedca8e1-091d-4c87-ad5f-(E-Mail Removed)...
> Ron, it maybe relevant but the e-mail addresses in the CC and BCC
> feild are formula derived, as like
>
> =IF(AY$10>=1,"(E-Mail Removed)","")
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Field Property (OldValue) not available in Field Object defined withDim As Field? insomniux Microsoft Access VBA Modules 2 11th Apr 2009 02:19 PM
In a sub-form : when entering a field, verify if another field is true, if so show a MsgBox + set focus on another field Céline Brien Microsoft Access Forms 4 14th May 2008 03:30 PM
I want to combine a date field and a time field into 1 field. Bob Quintal Microsoft Access 4 28th Sep 2007 06:29 PM
On a report, print field A or field B based on value in field C =?Utf-8?B?R2FyeSBGcmFj?= Microsoft Access Reports 4 1st Aug 2007 08:10 PM
2 Related field or Auto fill up 2nd field after 1st field entered =?Utf-8?B?S2FvbGk=?= Microsoft Access Getting Started 1 17th Sep 2006 11:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:22 PM.