Cell to textbox and back with only email addresses - email

I have a spreadsheet where Column M contains a header in M1 and cells M2 - M22 contain email addresses that are later used to email the sheet as a .pdf. I have found the attached formula to ensure the column only contains email addresses, but I'm trying to adapt it. The user will click a command button to pull up a UserForm with 22 TextBoxes used to either change, add, or remove email addresses for the email to be sent, and then put the email addresses in the TextBoxes back into the cells on the worksheet. (The cells will be locked and can only be changed by the UserForm.) But I want to be able to either list the order of text boxes by inserting numbers 1-22 into the blank cells to show the user the order to use - to prevent blank cells - and then insert the TextBox values back into the cells only from TextBoxes with a valid email. Any ideas how to adapt this code, or does anyone have a better idea?
If Target.Column = 13 And Target.Value <> "" And Evaluate("COUNTIF(" & Target.Address & ",""*#*.*"")") <> 1 Then
Target.ClearContents
Target.Activate
MsgBox "Please enter a valid email address."
End If
End Sub```
Thank you in advance for any help!

Related

Select from Contacts a List of People Based on Email Label Using AppleScript

Using AppleScript, how do I get a list of all people in the Contacts application who have at least one email address with a particular label?
I tried:
set peopleToCheck to every person where ((label of its email contains strContactEmailLabelHome))
Unfortunately, it returns an empty set. This can’t be correct because
set peopleToCheck to every person where ((label of its first email contains strContactEmailLabelHome))
Returns a set of one person.
property text item delimiters : linefeed
tell application id "com.apple.AddressBook"
-- Get the label of every email of every person
get label of people's emails as text
set labels to the result's text items
-- Remove duplicate items from the list of email labels
tell (a reference to the labels)
repeat length times
if string 1 = "" then set string 1 to 0
if string 1 is not in rest of strings then set end to string 1
set string 1 to 0
end repeat
set contents to strings
end tell
labels --> List of unique labels currently in use by at least one contact
-- Choose a label to match contacts against
set [specificLabel] to choose from list of labels ¬
with title ["Search Contacts by Email Label"] ¬
with prompt ["Select one of your email labels:"] ¬
OK button name ["Search"] cancel button name ["Close"] ¬
without multiple selections allowed and empty selection allowed
-- Matches
set P to a reference to (every person ¬
whose emails's label contains ¬
the specificLabel)
-- Select the matching contacts in the application
set selection to P
return name of P
end tell
set customLabel to "customLabel"
tell application "Contacts"
return people whose label of emails contains customLabel
end tell
Or, using variable for the list:
set customLabel to "customLabel"
tell application "Contacts"
set theList to people whose label of emails contains customLabel
end tell
return theList

Excel Form VBA Combobox reset

This should be easy but I can't seem to find anything to solve. I have a Form in Excel using VBA. The Excel sheet has four columns populated with data and the Form displays those fields.
The user then selects a value in a combobox, uses a command button to submit the responses and the values from the combobox are written to the Excel sheet.
The user then uses a command button to advance one row down in the spreadsheet and load the four values from a new row. This all works great.
The issue I am trying to solve is that the combobox remains selected to the value in the prior selection. I'd like to reset the combobox so nothing is selected and the user has to make a selection again for the next row.
Below is the code I am using to load the combobox and to set a variable for what the user selected. Can't seem to get the combobox back to it's default state after the user has submitted the form.
Private Sub cbDesAccWanted_Change()
Select Case cbDesAccWanted.Text
Case "Yes"
desacc = "Yes"
Case "No"
desacc = "No"
End Select
cbDesAccWanted.Text = desacc
End Sub
Private Sub cbDesAccWanted_DropButtonClick()
cbDesAccWanted.List = Array("Yes", "No")
End Sub
There are two ways to reset the combobox. Take your pick:
1
cbDesAccWanted.Value = Null
2
cbDesAccWanted.ListIndex = -1
the line
cbDesAccWanted.Text = desacc
is totally unnecessary.
Using cbDesAccWanted_DropButtonClick is not the right place to populate the list of values. This list should be set up when the form is first shown to the user.
(unelss the values it shows chnages in which case change it when the row changes or something, not when the user clicks on it)
So when theuser clicks the down arrow to move to thenext record include the following line
Me.cbDesAccWanted.text = Me.cbDesAccWanted.List(1)
Note (1) access teh 2nd item in the list which is No.
So this reset it to the default value of No.
Ok.

Crystal Reports multiple parameter screens

I am creating a report with crystal reports 2008. My report has 4 parameters that the user must input, lets say: var1, var2, var3, var4. When I open the report it brings up the prompt to enter var1, once entered the user clicks next, and it goes to a second screen to get the next parameter, and so on.
My question is, is there a way to combine all of these to one screen. When the report opens, it has 4 drop downs for the parameters instead of one at a time?
I have thought about (and tried) a parameter that accepts multiple values but could not get it to work for my purposes. I am displaying approx 6 fields related to each parameter selected. SO if var1 is entered there will be 6 additional fields displayed. If it is not selected the area remains empty. Essentially each parameter represents a column to display in the report.
If there is a way to combine the 4 parameter screens that would be great, if you think this can be done using a multi value parameter then that is all I need to know and I will keep at it.
Thank you
Probably did not go about this in the best way but it serves its purpose and thought I would share for future reference. In response to the comments above, the parameters are not linked and I was not using a sub-report.
I ended up splitting the GroupSectionHEader into 4 parts, one for each variable. The report not contained GroupSectonHeader1-5. Each parameter variable had its own section. The user could select the parameter or False from the parameter input dialog. I then used the section expert and for each Group Header in the formula box nex to Suppress (No-Drill-Down) entered isnull({#var#}) or {var#} = " " this is because my variables are strings. This way if the user chose False, the variable would be left black and this formula would pick up on that and hide that section in the final formula.
I am very new at CR so I doubt my explanation is as clear as it could be, nor the most proficient.

VBA form to show cell value

I have an Excel VBA form to enter data into a worksheet.
Last column of my worksheet CC contains a formula which calculates some input fields. It is a very long though simple formula.
Is it possible that while I am entering the data in the form, a field in the VBA form itself keeps showing me running result of the inputs made based on the formula in the worksheet column CC?
I don’t know how to write that long formula in VBA so want to find out if there is a way around it.
If not possible, how about while the data has been entered in the form, there is a button CHECK RESULT. Clicking this button temporarily enters the form data to spreadsheet, populating CC cell and that result shows up as message box while the VBA data form is still open.
This result message box could have two buttons, CONFIRM ENTRY or CANCEL.
If cancel is clicked then the data entered in the spreadsheet is deleted. If confirm is clicked, then entered data stays.
Kind of urgent if someone can suggest a solution.
I have added image of my VBA form.
In the most basic manner to answer your sub question:
"Is it possible that while I am entering the data in the form, a field in the VBA form itself keeps showing me running result of the inputs made based on the formula in the worksheet column CC?"
Yes it's possible.
Asumming have a working formula anywhere in the sheet. Which you do according to your question.
Assuming your Sheet doesn't have a code like Application.Calculation = xlCalculationManual , to say your Sheet is in automatic calculation mode it will show you the running results.
You use key press or enter events in the Form to update the Sheet column CC
Your approach with buttons and message box seems fine. Why don't you give it a try and let us know with any issues you face.
Some hints:
UserForm1.Show vbModeless property
Allow worksheet access while user form is open
Editing spreadsheet while user form is open
How to show messagebox from cell changed event while user form is open?

How to update another text box while typing in access 2007 form?

I have a few text boxes which have to be filled with numeric values from 0 to 100. Below them there is another text box which stands for a total (the sum of the values from the text boxes above). How can I update the sum text box while typing in any of the other text boxes above?
If you are happy that the sum box updates after a box is updated (enter, tab or such like is pressed), then this can be done without any code. First, you will need to set the format of the textboxes to be summed to numeric, then the control source of the sum box becomes:
=Nz([text0],0)+Nz([text2],0)+Nz([text4],0)+Nz([text6],0)+Nz([text8],0) ...
Note the use of Nz, it may be possible to eliminate this by setting the default value property of the various textboxes to be summed.
A large set of controls that need to be summed in this way is often an indication of an error in the design of the database. You would normally expect this kind of thing to be a separate recordset, which could more easily be summed.
I know this is old, but Google didn't come up with much for this topic and this thread didn't really help either. I was able to figure out a very easy way to do this, so hopefully anyone else looking for this will find this helpful.
My need was for actual text as opposed to numbers, but the same applies.
To do what the OP is asking for you'll need at least 3 textboxes. 1 is the textbox you want to have updated each time you type, 2 is the textbox you will be typing in, and 3 is a hidden textbox.
Set textbox 1 to reference the value of the hidden textbox 3 in its control source:
="something in my textbox " & [textbox3]
In the OnChange event of textbox 2 right a line that will set the value of the hidden textbox 3 to the Text property of textbox 2 that you are typing in:
Private Sub textbox2_Change()
Me.textbox3.Value = Me.textbox2.Text
End Sub
Each time the value of the hidden textbox 3 gets updated, the calculation/reference in the displayed textbox 1 will be updated. No need to save caret locations or anything else mentioned in this post.
I was able to do this in Access 2007 by using the On Lost Focus event of the text box.
Just put something like this on the On Lost focus event of each text box that you want to be added , just make sure to set the default value of each text box to 0.
Me.Totals.Value = Me.Text1.Value + Me.Text2.Value + etc..
The moment you click on the next text box or anywhere as long as it loses focus, your sum will already be on the Totals box. You may add as many text boxes as you like, just include them in the code.
This is problematic due to the asinine requirement in Access that you have to set focus to text areas before you can get their value. I would recommend you change your design so that the text field is updated in response to a button click instead of on change.
If you want to go the update-on-change route, you would attach change events to each of the addend text fields. The event handlers would need to save the caret position/selection length, update the sum in the output text field, and restore the caret position. You need to save/restore the caret position because this is lost when the focus changes.
Here's an example for two text fields (txt1 and txt2). The output field is named txtOutput.
Private Sub txt1_Change()
Dim caret_position As Variant
caret_position = Array(txt1.SelStart, txt1.SelLength)
UpdateSum
txt1.SetFocus
txt1.SelStart = caret_position(0)
txt1.SelLength = caret_position(1)
End Sub
Private Sub txt2_Change()
Dim caret_position As Variant
caret_position = Array(txt2.SelStart, txt2.SelLength)
UpdateSum
txt2.SetFocus
txt2.SelStart = caret_position(0)
txt2.SelLength = caret_position(1)
End Sub
Private Sub UpdateSum()
Dim sum As Variant
sum = CDec(0)
txt1.SetFocus
If IsNumeric(txt1.Text) Then
sum = sum + CDec(txt1.Text)
End If
txt2.SetFocus
If IsNumeric(txt2.Text) Then
sum = sum + CDec(txt2.Text)
End If
txtOutput.SetFocus
txtOutput.Text = sum
End Sub