LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Why variable isnt working

The code below is supposed to check a set of check boxes on a form, if they
are checked, add the strings to the variable (they are email addresses). this
works

The next section checks a radio button and is supposed to do the if then
else but that returns the strings from the check boxes too. I really want
that radio button to be a check box too. How do i differentiate that one from
the others that contain the email addressees?

Sub SendEmailBtn_Click()

Dim CBCtrl As MSForms.Control
Dim RBCtrl As MSForms.Control
Dim strReceipients As String
Dim MsgBody As String

'check to see what checkboxes are checked and add that email to the string
in recipients
For Each CBCtrl In RndmemailFrm.Controls
If TypeOf CBCtrl Is MSForms.CheckBox Then
If CBCtrl.Object.Value = True Then
strReceipients = strReceipients & ";" & CBCtrl.Caption
End If
End If
Next

' get the randomly generated subject line from column 2
SubLine = Cells(Rnd * (Cells(Rows.Count, 2).End(xlUp).Row - 1) + 2, 2)

' if the Use Automated message is checked, then randomly select a message
from column 3
' or else use the message in the message text box
For Each RBCtrl In RndmemailFrm.Controls
If TypeOf RBCtrl Is MSForms.OptionButton Then
If RBCtrl.Object.Value = True Then
MsgBody = Cells(Rnd * (Cells(Rows.Count, 3).End(xlUp).Row - 1) + 2, 3)
Else
MsgBody = RndmemailFrm.MsgBdyTB.Text
End If
End If

Next
MsgBox MsgBody
End Sub
 
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
Nested IF isnt working right..Why? Curtis Excel Worksheet Functions 1 October 30th 09 10:08 PM
Conditional Formatting isnt working right changetires Excel Discussion (Misc queries) 6 June 28th 06 08:47 PM
autofilter isnt working john mcmichael Excel Discussion (Misc queries) 2 October 19th 05 07:53 PM
AutoFill isnt working? M.L Excel Discussion (Misc queries) 7 June 16th 05 08:58 PM
Selection.count isnt working No Name Excel Programming 2 February 8th 04 03:23 PM


All times are GMT +1. The time now is 10:43 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"