Event Triggered When Renaming Sheet
Sep 29, 2008I need to declare an event that happens when a worksheet is renamed
the code that would trigger the event is
I need to declare an event that happens when a worksheet is renamed
the code that would trigger the event is
I have 2 worksheets ('pathways', 'pathway events').
'pathways' has unique rows with a unique ID i.e. [Pathway ID] whilst 'pathway events' has the same initial column [Pathway ID] but with multiple values of the same [Pathway ID] value.
If an [Pathway ID] value is selected in 'pathways', I want it to trigger some code which will open a new worksheet and copy the multiple rows in 'pathway events' with the same [Pathway ID] value and paste them into the new worksheet.
Is this possible to do in Excel. I normally use Access and you can have triggered events.
I have a manually calc'd workbook with the following code
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("VAL1CELL")) Is Nothing Then Me.Calculate
If Not Intersect(Target, Me.Range("VAL2CELL")) Is Nothing Then Me.Calculate
If Not Intersect(Target, Me.Range("CHOICE")) Is Nothing Then Me.Calculate
If Not Intersect(Target, Me.Range("$L$36")) Is Nothing Then Me.Calculate
If ActiveCell.Address = "VAL1CELL" Then Range("VAL2CELL") = Range("Y$41")
End Sub
Everything works as it should other then the part that is
If ActiveCell.Address = "VAL1CELL" Then Range("VAL2CELL") = Range("Y$41")
When the user selects VAL1CELL This is cell B2 and is a drop down, I want VAL2CELL which is C2 and also a drop down to show what is in Y41 (i.e the first name that appears in the drop down...not a thing happens ? is there a flaw to my code ?
Is there a way to trigger a macro when a shape is moved by the user? If I set the OnAction property for a shape, then the cursor changes to a hand when it is over the shape, and I can detect a mouse click on the shape, but I cannot drag and drop the shape. If I reset the OnAction property to "" (empty quotes), then I can drag and drop again within the worksheet, but I can't trigger the macro.
Worksheet_Change or Worksheet_SelectionChange are not triggered by this event.
People have suggested using timers to continuously poll the shapes and determine their locations, but is there an easier way?
What I am trying to do is create a sheet where the user can visually move around objects (in this case representing employees) and deposit them in various zones. The spreadsheet would then apply certain attributes to the shape i.e. change colour according to where the shape is and if it is in an unsuitable zone. I can do all of this, but I want it to work the instant the shape is moved, not rely on the user to hit a button.
I am using Excel 2007, and I have a macro (that is working) that I would like to run whenever there has been a new selection in a dropdown list on my worksheet. I have done this many times before in other workbooks, and I have always used:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
To my knowledge this should trigger the macro when the dropdown selection changes. However, this time it is not working. The macro runs fine manually, but it does not run when the dropdown selection changes.
I have a relatively complex excel VBA solution which has a top level spreadsheet containing a dashboard of stats (test statuses within projects).
There are various reporting options available which open other spreadsheets to collect data and present it within the top level spreadsheet - these are closed once the data has been copied.
For example, I select an option to show me all the issues relating to tests for a particular team and the solution opens a series of spreadsheets and copies the issues into the summary spreadsheet.
The problem is that the report has the option to double-click a row, which essentially opens the corresponding Excel file and focuses on the relevant row containing the issue.
This works fine but I've added protection to the report to prevent users editing the data here (they should double-click to open the underlying file and edit there).
The report is a protected sheet and locked/unlocked cells can be selected - in fact, they need to be to allow the double-click event.
If I put my cursor in a cell and click Delete then pass over the warning that the sheet is protected then select Enter, Excel raises error "1004: Select method of Range Class failed".I understand that use of worksheet select is not a good idea but what concerns me is that the event which occurred prior to the double-click (the one which collected the data for the report) is running when it shouldn't be so.
Why would the earlier event be triggering and why doesn't it hit my breakpoint placed in the related code block even though that must be running?
Basically the situation I have is Sheet2 has many references to cells in Sheet1. Sheet2 is for all intents and purposes a kind of nicely formatted report form, and Sheet1 is the input form.
My ultimate goal is to automatically resize row heights on Sheet2 when cell contents change on Sheet2.
Using a worksheet_change event isn't working I presume because it doesn't see the formula output change as a worksheet change, the worksheet_change is firing only when the input is changed in Sheet1.
how can I capture these formula output changes on Sheet2 (triggered from input on Sheet1) OR is there a way of making a particular sheets rows always adjust in height to best fit?
I have copied a sheet, moved it to the end and renamed it with a date that is in cell "A1"
Now after that process is finished I need it to update the date in cell "A1" of the newly created sheet with the next day's date.
I am stuck however referring to the previous sheet to update the date value in "A1"
Is there a way to write a Worksheet_SelectionChange (ByVal Target As Range) event in module after creating a sheet in VBA? I constantly delete a sheet, then repopulate it with a new one that is empty, but I need to add some code that happens if they should change a particular cell. It worked when I ran it on a worksheet without refreshing, but as soon as I cleared and repopulated the sheet, it was gone. Is there a way to preserve this?
View 9 Replies View RelatedI have a VBA Code which executes SSIS Package. Before executing that package i need to open the excel sheet saved in C:SSISPackages and rename sheet "SSISP"and then close the sheet..It will not be sheet1 but someother names(cannot guess)..
View 6 Replies View RelatedI got a workbook containing a worksheet called APheb1.
I would like to create a macro that would replicate this worksheet and rename it APheb2, APheb3 etc... till a number i specify. For example if i specify 90, then it would replicate APheb1 90 times till APheb90.
I have recorded a macro that replicates the file but i cannot find a solution for the renaming part.
I have the following code to move/copy worksheet and then copy and paste
special values. Is it possible during this process to get the user to change the 'moved' worksheet name ?
I have an excel file which consists of old name and new name in two different columns. I have 500 photos in a folder. I want to rename the photos with the new names when there is a match with the old name(same as that of image name) in the excel.
View 4 Replies View RelatedI have an excel file (2003 version) with one sheet called sheet1.
On sheet1 I have multiple text boxes, however each text box has the same text box number "Text Box 1244" (this number appears in the top left-hand side in excel when I click the textbox).
I was wondering if it's possible to rename the text boxes based on their location on the sheet.
Eg. If i had a sheet with 5 rows of text boxes and 3 columns of text boxes (15 text boxes in total).
The top left-hand box gets renamed to "Text Box 1", then the text box below that gets renamed to "Text Box 2" and so on to the bottom of the sheet to "Text Box 5". Then the vba script would move to the text box that was to the right of the first text box (1st row again but 2nd column), and rename all the text boxes in that column ("Text Box 6" onward).
The outcome would look something like:
TB1 TB6 TB11
TB2 TB7 TB12
TB3 TB8 TB13
TB4 TB9 TB14
TB5 TB10 TB15
I'm stuck on this problem a while now and cannot find any scripts to solve it. My VBA is non-existent, I usually get by on bits of code I find on the web.
I hope each textbox has a hidden co-ordinate associated with it, then it might be possible to loop through all the textboxes based on their positions and rename them.
I have finally got a Marco to run based on the value of a cell changing from 0 to 1 .
However once activated it run continually until Stack full error .
I am trying to do is trigger an event when a cell changes, and this cell is updated via a linked drop-down box.
The issue is that the code seems to work fine (in about 10 seconds or less) if a manual calculation is entered into the sheet - but when it's done via the drop-down box, it takes about 3 minutes to complete the macro.
I have a macro which makes an renames a new sheet for me using a button, how can I copy macros currently found in only one sheet to this new sheet? Mainly used in formating and formula display.
View 5 Replies View RelatedI need to identify the object that is triggering the current running macro. For example, i have 4 buttons say button 1 to 4 that all do almost the same thing. I have written 4 different macro for all 4 buttons but i want to simplify my code so that i can have a better leaner code by only using 1 macro for all 4 buttons. simply put is there a way to say identify which button/shape i pressed:
If "identity of button pressed" = "Button1" Then
execute some code
Else
End If
I have a worksheet called "Roster" with a list of names from D7:D17 each person on the list has a separate sheet that is called by their name. the sheets are not linked up. the names were just manually typed into the list and into each sheet name.
If any name is changed on the list on "Roster!D7:D17" i would like the sheet that has that name to change as well.
This is the code that i was sent, but i do not know enough about VBA code to understand exactly what is happening, thus i cannot diagnose the problem. I placed the following code into the page "Roster" (by right-clicking and then pasting the code) then i closed, but nothing happens. I can mess with the code and get an error message. but that is about it. error messages usually say something about the debugger, or runtime error or something.
there is the
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
OldVal(0) = OldVal(1)
OldVal(1) = Target(1).Value
End Sub
I wonder how to capture de event when one choose to delete a sheet. Similar to vbyes or vbno?? Now it inmediatley goes to my sheet_deactivate_event, but then I don't know if it is beiing deleted? I mean capture if you do righclick sheettab
View 2 Replies View RelatedI have a multi-sheet workbook. The first sheet is a summary of results from the rest of the workbook. I would like this summary sheet to auto-refresh itself each time the sheet is activated. The VBA code triggered by the Worksheet/Activate event feeds some parameters out to other sheets, then copies back the results to the summary sheet of the workbook.
While doing so, it keeps "reactivating" the first sheet, causing it to get into an endless loop that is triggered by the Worksheet/Activate event. Essentially, I'd like the Worksheet/Activate event to go dormant for 15 seconds or so each time it is triggered.
how to automate my excel sheet i have got.
It has code which when you click the "Save" button it saves the document and then converts a copy as CSV with the same name.
I have been trying to automate this to run every 2 minutes but everything i have tried does not work.
I have tried using OnTime events but again does not work.
I have a Combo Box on a Work Sheet that the user selects a subject from. When the Combo Box content changes I need it to run a macro. Ive tried putting this in the WorkSheet file for the sheet
View 3 Replies View RelatedI'm making a macro to show or hide rows depending on whether or not a checkbox is checked. I'm using Wingdings font checkboxes, not actual form controls. The question: My macro can't find the last row of the used range on the sheet. This is in the sheet's code, set to fire when the selection changes.
Normally the line in blue works just fine, but it's not working here. In the attached workbook, the macro thinks the last used row is row 19, when it's actually row 21. What's going on?
One of the things it does throughout the course of the run is unprotect the worksheet, do what it needs to and then reprotects the sheet (using a password). On the second run, the sheet protection input box is shown and I am required to input the password before the code will execute.
The code that I have written uses an Add-in that pulls data from a database. As part of that retrieval, the other add-in protects the sheet without a password. Would that be causing my error?
why this code does not work when the worksheet is changed between range "B1:F5"?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1:F5")) Is Nothing Then
With Range("B1:F5")
Cells(Target.Row, 7) = Cells(Target.Row, 6).Value + Cells(Target.Row, 5).Value
End With
End If
End Sub
I have a date base that is used as a job status board developed in excel that has locations, times, clock and other areas. What I am looking for is a way of playing a sound when the time approaches 5 min before the time in the excel cell that has been entered into the job status board...
View 3 Replies View RelatedCan a event be triggered when the Visaul Basic Editor command button is clicked in Excel?
I have many worksheets in a workbook that need to be saved if a user changesanything on them.
These sheet names all end in "....SD" and the code needs to only run on those sheets. I have learned alot from the forum but not enough, just yet . . This is what I have so far:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim sht As Object
For Each sht In ThisWorkbook.Sheets
If LCase(Right(ws.Name, 2)) = "sd" Then
MsgBox(Prompt:="You must save changes. Save now?", Buttons:=vbYesNo) = vbYes Then ThisWorkbook.Save
End Sub
It doesn't like the 2 "Then's". (Don't laugh - I'm trying.)
I have the following code what it does, is when a user changes a cell it copies the row to another sheet along with the userstatus. Problem is if the user pastes more than one column of data into the sheet it copies the row more than once depending on the amount of columns the user pasted . I only want to copy the row once.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim SelRng As Range
If Not Intersect(Target, Range("A3:K30")) Is Nothing Then
Set SelRng = Target
Application. ScreenUpdating = False
For Each cell In SelRng
Range(Range("A" & (cell.Row)), Cells(cell.Row, Columns.Count).End(xlToLeft).Offset(0, -5)).Copy
Sheets("Tracking").Select
ActiveSheet.Cells(Rows.Count, 31).End(xlUp).Offset(1, -13).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(0, 13).Value = ActiveWorkbook.UserStatus
Sheets("Engine 1").Select
Next cell
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
End Sub