Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Dim xxx As String & IF?

I am using CDO Mail to distribute reports. My script has been wroking great
and sends out multiple reports, however I now have to setup more that one
distribution list...

I already have logic that identifies what reports are being sent and want to
use something similar to choose the distro list, but I don't know if using an
IF statement is valid when defining a variable.

Here's a snippet of the code I am trying to use:

Dim SCType As String
SCType = sh.Range("K6")

Dim Distro As String
If SCType = "WFSCScheduler" Then
Distro = "
Else: Distro = "
End
End If

Yeah, I suppose I could put a formula in the sheet and define the distro
that way, but I really hate to clutter up my sheets... Also, I may need to
build additional distros, so additional Else/IF Statements may be necessary.

What am I doing wrong?

Thanks!
Ray

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Dim xxx As String & IF?

1) Take out the 'End' statement. That stops all code & resets all variables.
Do that and what you have will probably work fine.

2) If you expect you will be adding additional conditions, consider using a
Select Case structure rather than a If..Then..ElseIf: Unless you have a
simple either/or condition, I find it much easier to read, debug & maintain.

Select Case SCType
Case "WFSCScheduler"
Distro = "
Case "SomeNewValue", "NewWFSC"
Distro = "
Case Else
Distro = "
End Select


HTH,

"RayportingMonkey" wrote in
message ...
I am using CDO Mail to distribute reports. My script has been wroking great
and sends out multiple reports, however I now have to setup more that one
distribution list...

I already have logic that identifies what reports are being sent and want
to
use something similar to choose the distro list, but I don't know if using
an
IF statement is valid when defining a variable.

Here's a snippet of the code I am trying to use:

Dim SCType As String
SCType = sh.Range("K6")

Dim Distro As String
If SCType = "WFSCScheduler" Then
Distro = "
Else: Distro = "
End
End If

Yeah, I suppose I could put a formula in the sheet and define the distro
that way, but I really hate to clutter up my sheets... Also, I may need to
build additional distros, so additional Else/IF Statements may be
necessary.

What am I doing wrong?

Thanks!
Ray



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Dim xxx As String & IF?

I opted for the Select Case method and it worked great - Thanks!

"George Nicholson" wrote:

1) Take out the 'End' statement. That stops all code & resets all variables.
Do that and what you have will probably work fine.

2) If you expect you will be adding additional conditions, consider using a
Select Case structure rather than a If..Then..ElseIf: Unless you have a
simple either/or condition, I find it much easier to read, debug & maintain.

Select Case SCType
Case "WFSCScheduler"
Distro = "
Case "SomeNewValue", "NewWFSC"
Distro = "
Case Else
Distro = "
End Select


HTH,

"RayportingMonkey" wrote in
message ...
I am using CDO Mail to distribute reports. My script has been wroking great
and sends out multiple reports, however I now have to setup more that one
distribution list...

I already have logic that identifies what reports are being sent and want
to
use something similar to choose the distro list, but I don't know if using
an
IF statement is valid when defining a variable.

Here's a snippet of the code I am trying to use:

Dim SCType As String
SCType = sh.Range("K6")

Dim Distro As String
If SCType = "WFSCScheduler" Then
Distro = "
Else: Distro = "
End
End If

Yeah, I suppose I could put a formula in the sheet and define the distro
that way, but I really hate to clutter up my sheets... Also, I may need to
build additional distros, so additional Else/IF Statements may be
necessary.

What am I doing wrong?

Thanks!
Ray




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String Ron[_14_] Excel Programming 6 January 23rd 07 07:38 PM
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) Brian Excel Programming 3 February 9th 06 03:38 PM
Importing Long String - String Manipulation (EDI EANCOM 96a) Brian Excel Programming 6 February 9th 06 12:27 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


All times are GMT +1. The time now is 12:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"