Run A Button From Another Button From A Different Worksheet
Feb 8, 2010
i'm using excel 2003 SP2. I have several sheets with the same buttons. And i have a final sheet where I collect a summary from every sheet. I want to create in my summary sheet a button that runs all the buttons from the other sheets, so i can get all the info.
Running into this issue of "transworksheet macros"
I have a master "update" commandbutton on sheet 1. I have two sub "update" buttons on sheet 2 and 3 respectively.
What I would like to do is have the user click the master button, that would "click" the two sub buttons so they run their respective macros on their respective worksheets (within the same worksheet.
I have tried pasting the macro code in the master button, telling it to select the sub worksheet and then run the macro, but the marco runs itself on the master worksheet instead.
I have a togglebutton for an excel sheet in use for scoring psychological tests. When pressed, the button higlights the cells where a raw score is inserted.
What I need is a code to higlight the togglebutton when pressed, eg. green (colorindex 4). The button is white. How to do this?
Below is the code, It has more lines than needed, but it works.
Private Sub ToggleButton1_Click() 'FKV TOGGLE'
ActiveSheet.Unprotect "manisk" If ToggleButton1 Then
I received this code from an example I found once upon a time that was originally submitted by someone else. Right now the code enters the current date in a cell of the same row as the checkbox when it's checked. I need to revise it, or come up with something similar, that will reference the value of a cell when it is in the same row as the button (from the Forms toolbar) that is clicked to activate the macro. First of all, I don't know how to reference a Forms button in VBA.
Sub Process_CheckBox() Dim cBox As CheckBox Dim LRow As Integer Dim LRange As String LName = Application.Caller Set cBox = ActiveSheet.CheckBoxes(LName) ' Find row that checkbox resides in LRow = cBox.TopLeftCell.Row LRange = "B" & CStr(LRow) 'Change date in column B, if checkbox is checked If cBox.Value > 0 Then ActiveSheet.Range(LRange).Value = Date 'Clear date in column B, if checkbox is unchecked Else ActiveSheet.Range(LRange).Value = Null End If End Sub
Here is some other code I already created. Unfortunately, because I don't know how to do the row reference, I had to create 25 different macros, which just bulks up the size of my file and slows it down. But here is what I'm trying to accomplish in my macro:.............
i want to create a save button in sheet 1, on clicking the same the data entered in the particluar cells of sheet 1 should get saved in sheet 2 in given format
Context: I have a spreadsheet that contains a list of employee names and their certifications. I want to be able to assign a button to each employee in column B with a macro that is able to zip files from a folder that contains that employees name.
The following code assigns buttons to each employee in column B. At the moment the code I have is able to assign the macro "Zip" to each button.
[Code] .....
Now, this Zip macro is able to zip the file for the employee "Anthony Tran". However I need it to be able to recognise which employee's button I've clicked and search the same files as above except with that employees name instead of "Anthony Tran".
If it makes things easier, the code for creating buttons for each employee is able to name that button as the employees name that it represents.
This is probably really straight forward but cant see why it happens, the following macro works fine when called by a button created by the form toolbar but doesnt when called by a command button, get the runtime error 1004, "select method of range class failed"
Context: I have a spreadsheet that contains a list of employee names and their certifications. I want to be able to assign a button to each employee in column B with a macro that is able to zip files from a folder that contains that employees name.
The following code assigns buttons to each employee in column B. At the moment the code I have is able to assign the macro "Zip" to each button.
VB:
[COLOR=#333333]Dim Btn As Button[/COLOR] [COLOR=#333333]Dim rng As Range[/COLOR] [COLOR=#333333]For I = 2 To RowCount + 1[/COLOR] [COLOR=#333333]With Worksheets("Sheet1")[/COLOR] [COLOR=#333333]Set rng = .Range("B" & I)[/COLOR] [COLOR=#333333]Set Btn = .Buttons.Add(rng.Left, rng.Top, rng.Width, rng.Height)[/COLOR]
[Code]....
The following code is my Zip macro:
VB:
[COLOR=#333333]Sub Zip()[/COLOR] [COLOR=#333333]Dim strDate As String, SavePath As String, sFName As String[/COLOR] [COLOR=#333333]Dim oApp As Object, iCtr As Long, I As Integer[/COLOR] [COLOR=#333333]Dim vArr, FileNameZip[/COLOR] [COLOR=#333333]Dim FName() As Variant[/COLOR]
[Code]...
Now, this Zip macro is able to zip the file for the employee "Anthony Tran". However I need it to be able to recognise which employee's button I've clicked and search the same files as above except with that employees name instead of "Anthony Tran".
If it makes things easier, the code for creating buttons for each employee is able to name that button as the employees name that it represents.
I am imagining a spreadsheet with the equivalent of an info button in each cell of column A. The idea is the user clicks the button to open a User Form containing additional info about the entitity represented by values on that row.
E.g., Row 1 is labels, row 2 is all about Bob, 3 is about Jane, 4 is about Freddy. If the user clicks the info button on row 3 then a user form opens up and displays additonal info about Jane.
I am wondering if there is a way for VB to identify which row the clicked button was on without having to write individual code for each button telling VB which row the button was on.
I am hoping there is some form button property I can reference or interrogate which will give me a cell address; a button.position property or similar. This will obviously save me a lot of coding if VB can dynamically determine which row is being interrogated as there will be a couple of hundred of these to start with, potentially thousands. (I realise Access is a better solution for database interrogation, but I have to work with excel at present).
Ultimately, the user form that the button calls up will have a list box on it and I want the list box to default to the entity on that row, and allow the user to browse the other entities if they want to.
If there isn't a solution for this I will just have a single info button for the users to click that opens the user form and then they can select the entity from a list box. But I would like to offer the "intelligent display" option but don't relish coding the equivalent of several hundred "You clicked button four hundred and seventy six, default to info card for bert".
I have a workbook that contains 18 sheets, on 14 of the work sheets I have a comand button that runs the following Private Sub CommandButton1_Click() ' Range("B3:B53").Select ' Selection.ClearContents
Dim nloop As Long
Range("C3:K53").Select Selection.Copy
Range("B3:J53").Select ActiveSheet.Paste
For nloop = 3 To 53
If nloop 3 And nloop 12 And nloop 15 And nloop 16 And nloop 23 And nloop 28 And nloop 41 And nloop 47 Then Range("K" & nloop).Value = 0
Next nloop
Range("B2").Value = DateAdd("d", 7, Range("B2").Value) Range("L7").Select End Sub I want to put a comand button on sheet18 that will run the code so it does the same thing as pressing each command button on each sheet.
the sheets that I have the cmd on are: Sheet1, Sheet2, Sheets3, Sheet4, Sheet5, Sheet6, Sheet9, Sheet10, Sheet11, Sheet12, Sheet13, Sheet15, Sheet16, Sheet17
I have read several articles saying using a command button as a toggle button can't be done but some articles have said it is possible using the state properties.
.State = msobuttondown .State = msobuttonup
Is there any way to combine this with the onaction property so that when you press the button, it stays down and activates a macro then when you press it again it pops back up and activates another macro.
I have an existing button which has either a macro or hyperlink assigned to it which links to another worksheet within the workbook. I would like to change the worksheet it is linked to. I have tried right click - edit hyperlink and picked a different sheet, and also assign macro - record new macro. I have even removed hyperlink, then inserted new but no matter what it still goes back to the same sheet.
I am in this position after copying and pasting an existing button. I'm not sure how they designed it from scratch so I would really prefer to just change the link.
I have made a little program for a customer at work which has 4 different worksheets.
Each worksheet works out a cost based on different prices.
I would like to make a 'Welcome' worksheet, with buttons on it so my customer can click the button which corresponds to the option he would like to cost, and then excel automatically selects that worksheet.
how to create buttons but don't know the code to but behind it. It would be nice to also hide the other 3 worksheets when they have not been selected by the welcome page.
creating a button (using VBA code) in a excel worksheet that can initiate a range of output data in a col (say (C1:C100)) by activating the therein formula of each cell (same as what F2 does) and then entering the cell.
Actually I have to do manually each time for each output cell after opening the worksheet that I don't want.
I have a button on a worksheet that activates a macro, the macro is stored in a "personal.xlsb" file. This file is copied to several users computers so they can use the macro, problem is once the button is assigned to a macro from one computer all the other users can't use the macro. What can I do to make this macro work on all computers? (Less placing yet another button on the tool bar).
I want to assign macros to buttons from VBA. I know that buttons have a TopLeftCell property and I've used this before to point at cells around the button but not the other way round.
What I'm trying to do is have excel assign a macro to a button when the workbook is created (if thats possible - if not then just whenever it's opened the macro can be reassigned).
I'm working on an order form in excel and wondered if someone can tell me if it's possible to add a 'submit button' to a worksheet (order) that would do the following,
1.) print 3 copies (orders) of the current sheet
2.) create a new worksheet in the same workbook with a new order number (a specific cell in the worksheet) one higher than the current one. Also naming the new worksheet with the new order number.
3.) Save the current workbook.
Maybe I'm getting a little ahead of myself here but any help would be much appreciated as I'm really rusty at this...
I have buttons on each of my sheets, when one is clicked code is called in my module ("modAPI"), and from that code I wish to disable and enable certain buttons, and/or change the caption of those buttons. However when I try to do:
With ws btnRefresh.Enabled = False End With
I get Error 424, Object Required. I've tried recording a macro of what I wish to do, and it gives me ActiveSheet.Shapes("btnRefresh").Select, but this doesn't give me the option to enabled/disable or change the caption of the button.
I'm trying to make it so that when I hit one button it unlocks the ability to hit two other buttons. I've been trying to do some OnEvent things but they just haven't been working for me.
Ideally I'd like it so that button B and C look like they shouldn't be pressed, perhaps translucent or grey, before button A is clicked, after that they should turn to another a specified colour.
I have an expanding worksheet and would like to move a button so that it is always near the bottom of the worksheet data. When the button is pressed it reworks the worksheet and adds in some additional rows (up to 10 max). I'd like it so that the procedure also moves the button down keeping it in line with approximately the last row of data but not sure how to do this with vba...
I have created a calendar to enter various locations. At present they are set up using VBA and are called from buttons on the calendar. What I want to do is add a button to the worksheet and then edit its text. I will call a subroutine to use the edited text as the name I want in the calendar. What I cannot figure out is how to return the index of the button have just added so i can alter the button text. I appreciate I could cycle through all the shapes on the sheet but as I do not know the number of the one I have just added I cannot work on the correct one. I suppose I could cycle through all of them and use a carrier to count how many there are then add one to get the latest but that seems very crude not mention time consuming as I allready have 504 text boxes on the claendar.
I inserted a Command Button ("Button1") in a Worksheet ("Sheet5"). I want to disable this button while the vba is running. How do I refer to this form control from vba?
I am trying to create a simple macro to print a worksheet with a button. The worksheet will have additions/deletions on a daily basis, so it need to adjust accordingly. I cannot figure out how to do the loop macro.
I am trying to change the text that appears on a button on a worksheet via a macro. There is only one button on the worksheet so in the macro I use
MyCaption = activecell.value 'Pick up the button text from the spreadsheet For each sh in activesheet.shapes sh.caption = MyCaption 'I know this would do all, but only one button as I said next sh
which generates "Object doesn't support this property or method".
This is strange because if you get the properties box up, Caption definitely shows as a property of a button control.
I have data in several (50+) columns. I want to be able to sort all my data by the column I select with one click. So, I basically want a button over each column that sorts the data by that column. It would be ideal to have the same "Sort" macro that is attached to all the buttons. The macro should somehow know that the column the button is in, is the column to sort by.
Not to sure if it can be done but i would like to have a button on my spread sheet that once pushed it automaticaly saves my worksheet as a PDF in a selected company folder in my documents.
I know if you go to file and save as PDF, then save in selected folder will work, just looking for a quicker way so my staff just needs to push one button on the worksheet and it does it all. (dummy proofing the form i guess)