VBA / Creating And Attaching New Sub To Newly Created ActiveX Control?
Jun 2, 2014
After programmatically creating a new activex checkbox, I want to create a sub for it's click event. I have given the object a name, and fortunately the code for it's click event is a one-line call of another sub, but how?
The sub would look like the following except be named after the new control (obviously), and yes, it is just the number in the name that changes:
[Code] .........
View 2 Replies
ADVERTISEMENT
Jul 1, 2013
Using Excel 2010. I'm writing a macro that sets up a workbook to be used for estimating at the beginning of a project. In the code I need to create multiple tables (formerly known as "lists") in the workbook. Then later in the code I need to refer back to those newly created tables. Currently, the code that creates the table is part of a loop that creates the table on many different worksheets. The problem of course, is that I have to name the Table, and then it won't create a table of the same name on the next sheet. Then, later in the code, I need to make adjustments to the table that was just created before looping to the next sheet.
Is there a way to create a table without giving it a constant name? Or by giving it a name that builds off of other info in the sheet? For example, I would be good with the naming the table after the sheet name: "Sheet1_Table" or such.
Code:
Sub Auto_Open()
'
Dim sht As Worksheet
If Range("A1") = 1 Then
[Code].....
View 2 Replies
View Related
Jul 21, 2009
I originally posted this in the "Excel New Users forum" - i guess that was an error, but I'm very new (second post) and very new to VBA in general - so please be gentle!!
I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.
I then need to paste into this new worksheet a selection from another workbook.
How would I specify in the code that the selection needs to be pasted into the newly created tab?
View 12 Replies
View Related
Jul 21, 2009
I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.
I then need to paste into this new worksheet a selection from another workbook.
How would I specify in the code that the selection needs to be pasted into the newly created tab?
The code I have so far is as follows:
Worksheets.Add.Name = Workbooks("SHEET1").Worksheets("monthly report").[p1]
ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
Windows("SHEET1.xls").Activate
Range("A1:N23").Select
Selection.Copy
However, I got a subscript out of range error pointing at the line of
Worksheets.Add.Name = .Worksheets("monthly report").[p1]
View 9 Replies
View Related
Jul 1, 2014
I have an issue with saving the file at the desired location below is the code i have currently used . I have given the destination as "D:New folder". The new file does get saved at location "D:" but not inside the "D:New folder", instead names the file as "New folder".
View 3 Replies
View Related
Jun 18, 2009
I am trying to have the user hit a button and save the workbook in a newly created directory. Currently it creates the new workbook and the new directory with the correct names, however the workbook is not in the newly created directory.
View 5 Replies
View Related
May 11, 2006
I attach an example worksheet with the code I have thus far.
In my workbook I have other sheets, one of which changes and updates a specific one each time a new client's data is entered on said other sheet. Because I want to save the specific client's data and not lose it when another client's stuff is entered on this other sheet, I copy the sheet where the data is summarised (I called this sheet "Sheet to Copy From") to a newly inserted sheet and use Paste Special, Values Only to change all functions /f ormulae / Links ect to values.
I then change the name of the sheet to the name of the client.
I then use this sheet name / cell value to polulate a range on another sheet (Next Empty Cell) as a Hyperlink to the newly created sheet above. This sheet I called "Table of Contents".
how to code the hyperlink. Using Macro Recorder uses the specific case's names, but the Tab name to be used as Hyperlink value will always be the name of a new client,
View 8 Replies
View Related
Aug 9, 2008
My code in the first workbook generates a new workbook with a variable in the filename, then copies the cells from the first workbook to the newly created workbook. This code is working properly when used in a draft worksheet I use for testing. As soon as I put it in the master file, an error message pops up "Runtime error 1004 : select method of range class failed". Then the debug sends me to the line " Cells.Select ". What should I be looking for, why does my code work on one file but when i put it in another one it doesn't ?
Private Sub CommandButton1_Click()
Dim line_counter As Long
Dim prm_line_value As Boolean
prm_line_value = False
Do
prm_line_value = Sheets("Rate").Cells(1 + line_counter, 1).Value
line_counter = line_counter + 1
Loop Until prm_line_value = False
line_counter = line_counter - 1
Dim Wk As Workbook
Dim number_of_new_wb_needed As Integer
If line_counter < 5000 Then.....................
View 3 Replies
View Related
Mar 4, 2010
I created with code to copy a template, hide that template, and pop up a box to rename the copy, I noticed she clicked "Cancel" on the InputBox. When she did, she received an error (400). What I would like to do is when the "Cancel" button is clicked, the newly created copy would be deleted. Is this possible?
Here is the code for my full "Create New Project" sheet procedure:
Sub CreateNewProject()
'This code will copy the Project Data sheet, hide it and then
'rename the new copy to the MSA number. Code also prompts user for
'MSA Number and fills that in on the form.
Dim RenameSheet As String
Dim oSheet As Worksheet
With Sheets("Project Data")
.Visible = -1
.Copy After:=Sheets("FHWA Quarterly Report")
End With...............
View 9 Replies
View Related
Jan 9, 2012
I am trying to create a workbook where the first worksheet has a list of Checkboxes and each checkbox 'unhides' or 'hides' subsequent worksheets within the workbook, depending on whether the box is checked. I can make the checkbox, I can record the macro.
Sub Test_checkbox()
' Test_checkbox Macro
Sheets("Dist").Visible = True
End Sub
How do I link them together? Ideally, I'd like to have my boss be able to 'play' with which sheets are visible (check, uncheck, check, uncheck, etc) .
View 4 Replies
View Related
Mar 16, 2012
What the max length of an ActivX Control name would be. I mean the name that you would use in coding something, not the actual caption name of the button. IN this case I am using a radio button.
Based on that I would like to create random IDs to assign to the button. I know how to do this in the cell formula but not in code.
View 3 Replies
View Related
Jul 28, 2009
I copied a routine from this forum that would email a single sheet from a 10-sheet workbook to a recipient. This worked great for a long time, then all of a sudden I started getting the "ActiveX control can't create object" error. Here is my
View 14 Replies
View Related
Jan 6, 2010
I have an ActiveX Label control with a transparent background. When I click on the label the background turns white and stays that way as long as the mouse is over the label, obscuring whatever's underneath. (It also very slightly alters the character spacing.) What object/property controls this? How do I adjust it?
While I'm here, is there an easy programmatic way to assign arbitrary RGB colors to ActiveX controls? The palettes available from the Properties window are fairly limited. A google search for "ActiveX colors" yields a deluge of marketed products, so it's hard to find useful information.
View 4 Replies
View Related
Jun 10, 2008
Version: excel 2003
OS: Win XP
Currently using VBA do develop a tool for Excel. I've downloaded a .ocx control and am wondering how one would go about adding it to the toolbox?
View 3 Replies
View Related
Aug 13, 2014
Since Form Controls comboboxes don't allow font editing, I need to switch to ActiveX...
The combo box values come from the following cell range:
tbl_arrays!$I$3:$I$6
Those values are, from top to bottom: "select distance", "50 Miles", "100 Miles", "150 Miles".
The following macro is also assigned to the combobox:
[Code].....
I have two issues. The first is that the macro doesn't seem to be working. It is supposed to filter a list of cities within 50, 100 and 150 miles of a user input zip or city. The original Forms Control combo works but not ActiveX after I put the code in the change event:
[Code] .........
The second issue is that the last clicked value in the ActiveX comboBox replaces the top one.
Ex: from top to bottom, the combobox should display:
[Code] ........
but if the user clicks "100 Miles", the combobox is then going to display
[Code] ......
If the user then select "50 Miles", the box displays:
[Code] ........
View 4 Replies
View Related
Feb 18, 2014
I have created several macros where i use an active-X control button. This button is pressed and the macro begins...........but every now and again this button changes size for no apparent reason.
I have read countless articles/posts about what "may" be causing the problem but i have never read anything which clearly identifies the soln to this problem and the problem has been out there for years. To make matters worse the problem can not be duplicated on any regular frequency that i am aware of............so its not like i can post a file that will show the problem.............
View 4 Replies
View Related
May 14, 2014
I am using the following code to copy a template to a new worksheet each month:
Code:
Sub CopyTemplateNewMonth()
Application.ScreenUpdating = False
Dim SourceRange As Range, DestRange As Range
[Code]....
Everything copies over except an Activex Control button. I also have form control buttons with macros assigned to them, and they copy & paste just fine. The code assigned to the ActiveX button also copy's & paste's just fine...but the button itself does not.
View 9 Replies
View Related
Nov 23, 2007
RE: Macro ActiveX Click Control--It stops when on another sheet
Macro runs OK when run from menu.
An activeX click button was put on sheet B.
Right click the control, View Code, Paste in code from macro, then click button.
It runs the part of the macro that applies to sheet B, goes to previous sheet A, and then stops. The range select line for the named range on sheet A is highlighted in yellow. It stops when selecting any range or cell on sheet A, like B2.
Any idea why this code does not work on sheet A when ActiveX button is on sheet B? Is there someplace else that the control can go? Using Excel 2000.
See part of code below, which starts on sheet B:
' Macro recorded 11/22/2007
Range("SortAll").Select
Selection.Sort Key1:=Range("T2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ActiveSheet.Previous.Select
Range("FormBase").Select (STOPS HERE)
Selection.Copy
Range("Formul").Select
ActiveSheet.Paste
ActiveSheet.Next.Select
FormBase is a named dynamic range
FormBase=OFFSET(A!$A$2,0,0,1,MATCH(1E+306,A!$2:$2))
View 9 Replies
View Related
Feb 21, 2014
I have an excel application which works extremely well in one single instancec. It has a bunch of ActiveX control objects on the worksheet. Generally I call them by convention Sheet1.Cmd.show.
I have since experimented with having multiple instances of excel running on the machine. I start to notice something very strange. The first instance I open and run all the activeX buttons are all clickable. As soon as I open a second instance of an excel program all the activeX buttons on the worksheet are not even clickable. They are enabled by my program, but not clickable as if they were not there at all.
I also try open a normal excel workbook then followed by my excel program in a second instance. Even though the first excel file does not utilize any activeX objects all my buttons on the subsequent instance are not clickable.
The weird thing is all my activeX control objects on a userforms are still clickable and call to all my planned events in my program. It is just all the activeX controls on my worksheet that do not have any reaction at all.
I always think when one opens a new instance it will be totally indpendent and would even occupy another CPU if my machine has more in it. If they are truly independent then I am at a loss to understand why my activeX controls would fail to work at all.
View 8 Replies
View Related
Mar 15, 2012
I have a form that collects four pieces of information from the user and places each into columns A, B, C, D on a sheet. I would like to automatically add an option button to column E so that a user could select it and then click a control button to delete the corresponding row.
Is this possible or is there maybe a better way to do this in Excel 2007.
View 1 Replies
View Related
Feb 20, 2014
Can Active-X control button macro be placed in a regular module, or does it always have to reside in the sheet module?
Or is the only way to accomplish this is to have the macro in the regular module being called from the button macro in the sheet module?
I somehow seem to remember a way to move/assign an Active-X ControlButton macro to a regular module, but maybe I'm wrong?
View 1 Replies
View Related
May 12, 2014
I have a worksheet that contains a number of ActiveX image controls, which have been scaled to a uniform height to serve as thumbnails.
I have also created a class, where each instance is initialized with one of these image controls, and events (specifically the on click event) are captured. When the user clicks the picture, it opens a userform containg the same picture. However, I'd like that picture to be at its original size, not the scaled-down size.
how can I determine the original dimensions of a picture used in an image control? I can tell that the original resolution is there (by changing the PictureSizeMode to clip), but I can't find any properties that show me how big that image actually is, only ones that return or set the size of the object itself.
View 1 Replies
View Related
Sep 8, 2006
I've several check boxes on a worksheet. Some of the check boxes control the values of other through the _click event. However, when I try to change the value the event attached to the control in questions fires.
application.enableevents = False
would prevent events being fire from within the macro but this only seems to work when I step through the code.
I understand that I could set a global variable to do this and will probably go down this route anyway - but I am interested to know how/when I should be using the EnableEvent method (as I am sure this should be the way that I use it)
View 9 Replies
View Related
Aug 16, 2006
I have code that creates a row of controls on an MSForms.Userform at runtime.
I would like the user to be able to save these controls so that they are available the next time he opens the form. The user would be able to add or delete a row of controls and save them AND the values that he has set. This allows great flexibility for each session using the form.
The values aren't a real problem - I've been using the SaveSettings function for the design time controls values. The runtime controls are combobox, textbox, listbox, checkbox.
I don't want to design-time build the controls and just toggle the visible property (not a good solution for my app).
View 3 Replies
View Related
Apr 20, 2014
In A1 there is an ActiveX Control Text Box inserted, now in A1 cell which is beneath this text box contain the formula that if A9 is blank than "Customer Name" should appear else it should show blank. But the problem is when I write some thing in this text box which is connected with A9, formula works as "Customer Name" disappears but when I delete in text box it simply acts as if something is still present in cell A9 and formula does not comeback to "Customer Name" again & therefore in order to appear "Customer Name" I have to go to A9 and press delete button to get the desirous result from the formula.
Readers are requested to make this formula work becz the situation in which this formula has been invented is well fitted and not other formula can supplant it.
View 1 Replies
View Related
Jan 28, 2009
how to change the color of a command button created by using the control tool box
View 2 Replies
View Related
Oct 26, 2011
My workbook simply has multiple columns of data which will be summarized visually in a tag cloud (I have the tag cloud part taken care of already creating either a jpg or png, I simply have to change the extension within a batch file to change between picture formats)
I need to have the tag cloud image display and update depending on which column the user would like to summarize (for now I have simplified the issue by only having one of the data columns in my workbook, and will worry about the user selection of the data column to be summarized later).
My Main Question:
Focusing on the image display and updating now, whether it be an ActiveX Image Control or any other way. I've been playing around manually before I try and code it and I can not get either a jpg or png file to attach to the ActiveX control (both of which cause an Invalid Picture Message).
The file name can stay the same if need be and for now I think/assume that'd be easiest (I have my Tag cloud generator just replacing the previously existing image file of the same name).
Would ActiveX control be the way to go for this dynamically changing image?
View 9 Replies
View Related
Jan 29, 2007
I am trying to create a text box using the format control, however, everytime I click on the box it go to visual basic editor. I believe I'm missing something. I am not familiar with visual basic.
View 9 Replies
View Related
Jan 18, 2009
I am using the VBA Chart Control and I have the following instruction;
Me.ChartSpace1.Axes(ChartAxisPositionEnum.chAxisPositionCategory).Numb erFormat = "mm/dd/yy"
The chart is a "chChartTypeLine". the problem is that i cannot change the format of the X-Axis to a Date (mm/dd/yy) format no matter what I try? I keeps wanting to keep it as "General", here is the code;
Private Sub CommandButton1_Click()
Dim ser As ChSeries
Dim cht As ChChart
Dim MinValue As Double
Dim MaxValue As Double
MinValue = Sheet1.Range("D2").Value + 10
MaxValue = Sheet1.Range("A2").Value
View 9 Replies
View Related
Jun 20, 2007
What would be disabled that is preventing me from adding attachments to my posts? I click on the paperclip and the button "Manage Attachments". Nothing happens.
View 6 Replies
View Related