I have a Sub() in a module that sends an email to address that it retrieves from a spreadsheet.
See portion of code below
HTML Code: Do vaRecipient = Application.InputBox( _ Prompt:="Please add the name of the recipient such as:" & vbCrLf _ & "firstname.lastname@example.org or just the Staff ID.", _ Title:="Recepient", Default:=Range("I" & vaRow).Value) Loop While vaRecipient = ""
This is basically showing 3 popup boxes one after the other to verify each address,
Is it possible to either have it show an input box with 3 fields or ( what I'm currently trying) is to show a Userform . I have tried Userform12.show but it isnt working.
I have a project with many textboxes on different forms. On some of the textbox_exits on some of the forms, I call a standard module that checks what the user has input. If the user needs to change the input, a msgbox appears to inform the user the info needs to be changed.
I have tried to use ControlSource, Name etc., But I cannot seem to setfocus back onto which ever textbox the input needs to be changed. I think it has something to do wih the _exit event, but not sure.
I am trying to use some code similar to what i have used in one of my Modules in a Userform (The module calls this userform)
I have declared a few variables in the module:
Code: Public LastRow As Long Public TabLen() As Integer Public AHUArray() As String Public ArrayDim As Integer
and i want to try and use them in a userform (i call the userform through an bit of code that usures that the other subs that assign values to the variables have been used so there should be values in the variables??i think?)
i get to this line in my userform
Code: TabPos = TabPos + TabLen(i)
this is the first line that requires a value to be in the array and it errors: Subscript out of range
I just want a few variable that are used in a module to be available in other modules and userforms.
EDIT:the (i) is decalred in this sub within the userform. A thought occurs, the sub in the userform is a private sub, might that effect it?Also, explain Sub vs Private Sub vs Public Sub?, im new to this! the sub that fils the arrays in the module is just Sub SubName_Click()
I have a splash screen (user form) which displays fo a number of seconds. The UserForm_Activate routine uses Application.OnTime to run the KillSplash subroutine, which is defined in Module1. Thing is, I would like to move the "KillSplash" routine to the UserForm module. What should be the full name of KillSplash I need to pass to OnTime? What "trick" do I use to make "KillSplash" visible to Application.OnTime?
I created in module custom toolbar with a button, see the
Option Explicit Public ctrlGUI As CommandBarControl Sub CreateToolbar() Dim cb As CommandBar On Error Resume Next Application.CommandBars("Cust").Delete On Error Goto 0 Set cb = Application.CommandBars.Add( Name:="Cust", temporary:=True) With cb .Visible = True Set ctrlGUI = .Controls.Add(Type:=msoControlButton, temporary:=True) With ctrlGUI .FaceId = 3205 .Style = msoButtonIcon .............
I would like the users to be able to exit the whole module via double clicking the form. When the form is double clicked, the double click event appears and I am wondering how to put code into this procedure which exits the whole module.
I have a macro that when it runs presents a form that gives the user an option to skip the calculations or continue. If they click Skip then it continues the 'Next CE' . My problem is I can't get the Boolean value to pass from the form to the macro. Here is what I have
The main macro
Sub Dividend_MF() For Each sh In ActiveWorkbook.Worksheets( Array("G&I", "Growth")) For Each ce In sh. Range("a5:a" & sh.Range("a65536").End(xlUp).Row) If Not IsEmpty(ce) And Not (IsError(ce.Offset(0, 56))) Then If ce.Offset(0, 56) = "X" Then
I am using Excel 2010 and late binding to generate reports. The sheets are blank and unused. I have the UserForm being opened on Workbook_Open and the actual VBA for doing the work in a separate macro in the workbook. All the posts I have found are dealing with accessing cells from the UserForm and I haven't found any dealing with connecting a macro to the UserForm output.
My question is this: I want to return from the UserForm the flags of which reports to run to the (unopened) macro containing the code to do so. How do I open the macro and pass the variables to it?
The UserForm is creatively called "SelectionForm" and the macro is called "DailyFTP" with a Main sub as the entry. I know I can use the code under to capture the radio button and checkbox choices. I have other variables like the names of files set as global variables in the DailyFTP macro. The macro doesn't exist until SelectionForm opens it, so they must be set after the macro is in memory.
After all the awesome macros I've obtained with the help of all of you, I now have over 30 macros, each in its own module. I have tried without success to re-name the modules with no luck. How is everyone organizing these?
What i have at the moment is a module that contains code where i call a different module that i use as a procedure.
Code: If Sheet1.Range("C4").Value < Sheet1.Range("A2").Value Then If Sheet1.Range("K4") = "" Then MsgBox "Please check 06:00 tasks not done yet!" Cell = "Range(" & Chr(34) & "F4" & Chr(34) & ")" If Sheet1.Range("C4") + 0.042 < Sheet1.Range("A2") Then Run "EmailProSheet" End If End If End If
EmailProSheet is what i call but now i want to use the variable "Cell" in the procedure as well?
Code: MsgBox Cell Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next
As it is now everything is working fine but does not return a value in "Cell" if the procedure is called. Is there another way?
I inserted a second module into a project. Now I want to delete it. Only i can't figure out how to do this. I highlite it and right click or click edit from the toolbar but i'm provided no options. I can't drag it to the trash either.
I have a Form that when the 'SUBMIT' button is clicked, I would like to validate the information and then write it to a 'MASTER SHEET'. However, the validation has gotten lengthy and I have opted to put the validation code in a separate Module to keep my general code a little cleaner.
The original code would kick you back to the form if something was wrong via a 'END SUB', but as now the SUB is on a different Module, it isn't working.
Here is the pertinent code on the general code sheet: ....
I have 3 modules that all use the same Excel Workbooks, but just perform different actions in each module. It's such a waste of space! I was wondering if there was a way that I could combine all 3 modules into one module.
For example Module 1 is:
Code: Dim Varbooks Dim varBook Dim wb as Excel.Workbook Varbooks = Array("Fire", "Ice", "Alpha") For Each varbook in Varbooks 'Run the below code Next Varbook
Module 2 reads:
Code: 'declare all variables CurrentPath = ActiveWorkbook.Path varBook = Array (same varbooks as above) 'Run different code Next varbook
Varsheets (I use varsheets instead of varbooks this time only difference, but they are sheets inside a masterworkbook, as opposed to being workbooks themselves, but exactly the same names)
'Run a totaly different code here
Is it possible to somehow combine all 3 of those into one module? I have tried, but I keep getting a compile error of "For Control Variable Already in Use"
I have code broken out between two different modules due to size limitations in a single module. I'm not able to figure out how to move to the second module after running the first module. I've tried something like this:
Sub FirstModule() 'Code 'Code 'Code SecondModule End Sub
Sub SecondModule() 'Code 'Code 'Code End Sub
I'm getting an error that says "Compile error: Expected variable or procedure, not module". I understand that it's not allowing me to use the name of a module as a procedure, but I can't find any information on how to call the second module.
I defined function ConcatenateIf() in Module 1, that would take a range and combine the cell contents:
Function ConcatenateIf(iRange As Range, iLook As String, iNum As Integer) For Each cell In iRange If cell.Value iLook Then ConcatenateIf = ConcatenateIf & Chr$(10) & cell.Offset(0, iNum).Value End If Next cell End Function
Works beautifully. Then I save, and close. When I re-open, all the cells that reference this function display #NAME? error, like it can't find the ConcatenateIf() function. Does this have something to do with macro security? If so, why would it work at first, and then stop working?