As a test, I created a userform called UserForm1 in a workbook. In the same workbook, I placed an ActiveX button on Sheet1. In the code for Sheet1 I placed:
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
When I click the button, the form appears.
Are you doing anything...
Where does UserForm1 reside? Is it in the workbook with the command button, another workbook, or an add-in?
Chris
-------------------------------------------------------------
"Don't be deceived. We're all temporary employees.
Try using
Me.Show
instead of UserForm1.Show
Chris
-------------------------------------------------------------
"Don't be deceived. We're all temporary employees.
Does anyone know how to get VBA macros to continue running after the computer has been locked? I have macros that I would like to run overnight but the computer must be locked in my absence. As far as I can tell, execution pauses when I lock the machine and resumes when I unlock it.
Chris...
I see that your row index variables are defined as Integer. Integer is limited to a max value of 32,767. If you have more rows than this it will fail. Use Long for row indices.
Dim LSearchRow As Long
Dim LCopyToRow As Long
Chris...
I just noticed something else, unrelated, in your code.
Dim LastRow, i As Long
is equivalent to
Dim LastRow as Variant, i As Long
if your intent was for both to be Long you must explicitly define them both.
Dim LastRow as Long, i As Long
Chris...
Thanx for all the assistance. Strongm's code was particularly helpful. I never would have figured this out on my own.
It turns out that capturing the form's Activate/Deactivate messages didn't quite get me what I needed. They are only sent when changing applications, not changing focus...
You have a typo: Set asANI should be Set wsANI.
asANI is actually referenced in multiple places, just not in the "Set tblr" line.
I find that using OPTION EXPLICIT greatly reduces these errors.
Good luck.
Chris
-------------------------------------------------------------
"Don't be deceived...
It's a rather simple application. I keep having a need to copy curves from one graph to another...sometimes on the same worksheet, sometimes to a different workbook.
I select a curve on a graph, press "Copy Curve", then store as many of the relevant parameters as necessary.
I then select the...
Ultimately I'm trying to set the Enabled state of the controls on the form based on conditions on the active worksheet, and doing that in an "OnFocus" event handler is the approach I use in other languages. I was hoping I could possibly set up a custom class for the form "With Events" but I...
Sequence of events:
1) I run the macro that displays the form on the desktop.
2) UserForm_Initialize() & UserForm_Activate() are fired and the form has focus.
3) I select a cell in the worksheet, the form loses focus, the worksheet gains focus. UserForm_Deactivate() is not fired.
4) I click on...
Yes. They aren't being fired when the focus changes.
Chris
-------------------------------------------------------------
"Don't be deceived. We're all temporary employees.
I need to know when my UserForm has gained or lost focus. I haven't found an obvious way of capturing these events. The closest things I've found are the Enter and Exit events for individual controls, but not the UserForm itself.
Any ideas?
Chris...
So far, my options haven't changed from when this first came up.
1) I can have the user manually reassign the button on the new worksheet.
2) I can place the macro in a module and force the user to copy it along with the worksheet to any new workbooks.
3) I can add another macro to automate the...
I may be missing something here. I'm not using any code for the copy operation. I'm merely trying to set up the worksheet such that a user can move or copy it within, or between, workbooks without having to reassign the macro to the button.
Chris...
No luck. It seems to want a hard reference to a worksheet (workbookName.xlsm!Sheet1.macroName), or just the macro name from a resident module.
Chris
-------------------------------------------------------------
"Don't be deceived. We're all temporary employees.
I have an Excel worksheet with a macro embedded in it (not in a module). This macro is invoked by a button on the worksheet. When I copy the worksheet, the macro and button are copied with it, as intended. Unfortunately, the button on the copied sheet points to the macro in the original...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.