Macro Runs When Change Cells In Totally Different Sheet?
Jun 18, 2014
So I have a worksheet that has a lot of macros in it. I have just barely run into a problem that happens anytime a change a cell in another workbook that I have open. The second workbook I have open isn't even a macro enabled workbook. But for some reason it gives me an error and says I am trying to run this code.
[Code] ....
It gives me the runtime error 9. This code is supposed to run when I click on a combobox in my main workbook but it is running anytime I change something in my other simple workbook. Why this happens and how to stop it? I have had a lot of similar problems in the past but I just dealt with it by only having one workbook open but in this case I will need both.
View 2 Replies
ADVERTISEMENT
May 26, 2009
Is there a way to prevent the Workbook_SheetChange event macro from triggering when I run Excel's Solver?
The solver goes through 100 or so iterations changing multiple cells each of which seemed to trigger the Workbook_SheetChange event. If there was a Solver Run event, I could turn off application events, but as far as I know such an event does not exist.
View 9 Replies
View Related
Dec 3, 2008
When I step through a macro (sessions) or run the macro seperately, it works as intended. When I have it run off of a worksheet_change it doesn't work. Is there an easy fix for this?
Original
Sub sessions()
Dim a As Integer
Dim x As Long
x = Sheets(1).Range("a" & Rows.Count).End(xlUp).Row
Sheets(1).Unprotect Password:="password"
For a = 2 To x
If Cells(a, "m") = Cells(a, "d") And Cells(a, "m") 0 Then
Cells(a, "f").Resize(1, 6).Select
Selection.Locked = True
ElseIf Cells(a, "m") Cells(a, "d") Then
Cells(a, "f").Resize(1, 6).Select
Selection.Locked = False
End If
Next a
View 9 Replies
View Related
Feb 3, 2012
I need to totally ungroup existing grouping of rows in a sheet. Totally ungroup = strip it totally of any grouping. In short, it should be back to its original state of no grouping at all.
Problem is that I do not know if the sheet has existing grouping, or if it does, how many levels of grouping.
The solution I have in mind right now is just to indiscriminately run ungrouping vba line 10X and just place an error handler i.e.
Code:
Sub Macro1()
On Error Resume Next
Range("A5:A29").Rows.Ungroup
Range("A5:A29").Rows.Ungroup
Range("A5:A29").Rows.Ungroup
Range("A5:A29").Rows.Ungroup
Range("A5:A29").Rows.Ungroup
[code].....
Is there a shorter way to handle this code-wise?
View 3 Replies
View Related
Feb 24, 2011
I am using Excel 2010 and I have a password protected workbook with password protected sheets that uses several macros. Most of them, in order to run, have to un-protect the sheet and then re-protect it again. This has been accomplished easily enough by adding ActiveSheet.Unprotect Password:= "mypassword" and ActiveSheet.Protect Password:= "mypassword" to the appropriate places in the script. All of my macros, which do various things like sorting and moving data, deleting blank rows, displaying dialog boxes containing warning messages etc. run fine.
My problem is this: when I password protect the sheets manually, I have checked the following options in the "Protect Sheet" dialog box. Under "Allow users of this worksheet to" I have checked 1)Select unlocked cells and 2)Format cells. After entering my password and closing the dialog box my sheet is protected, but I can edit cells in the manner my allowances permit. However, once I run any of the macros that un-protect and re-protect the sheet, I remain able to select and edit unlocked cells (practically, for my purposes, this means that I can input data which will appear in the default font size and color of the sheet) but I cannot format cells (which, practically, for my purposes would allow me to occasionally change the font color and size of the data). Naturally, after running a macro, the other cell-formatting options are unavailable to me as well. Is there any way to get my manual selections to remain in place after running a macro that functions as mine do? Or is there any way to make my manual selections the default settings for a protected sheet?
View 4 Replies
View Related
May 13, 2014
I have an automatic macro that runs from every sheet but is only based on one sheet. I had to protect the worksheet and in order to make the macro work I had to add an unlock and a lock code. The problem now is every time a user enters something it looks back to the other sheet and then comes back. Is there a way to prevent the user from seeing this. See code below
Private Sub Worksheet_Calculate()
Sheets("Profit Calc Local Currency").Unprotect Password:="hspricing1"
Application.EnableEvents = False
Dim lr As Long
lr = Cells(Rows.Count, "XEA").End(xlUp).Row
Range("$XEA$1:$XEA$" & lr).AutoFilter Field:=1, Criteria1:="1"
Sheets("Profit Calc Local Currency").Protect Password:="hspricing1"
Application.EnableEvents = True
End Sub
View 5 Replies
View Related
Feb 18, 2014
I have a workbook that uses the values that a user had entered into 3 cells to calculate multiple other charts/diagrams on multiple sheets within the workbook. Each sheet would show what the user had entered in the 3 cells to allow them to see what is being used to calculate each table. Is it possible to link these cells so that the user can change the 3 values without having to go back to where he originally entered the 3 values?
For example, a user has entered in 3 values in Sheet 1. A formula in Sheet 2 displays what is entered by the user and uses these calls in Sheet 2 for calculations. When the user wants to change the three values, he would have to navigate to Sheet 1 and enter in the new values to have the workbook recalculate all the tables. Is there a way to link the three cells from Sheet 1 and Sheet 2 so when the user is on Sheet 2, he has the opportunity to change the values on the current Sheet without having to navigate to Sheet 1 to do so?
View 1 Replies
View Related
Apr 9, 2014
I am trying to create a scoreboard or leaderboard for my job. I am using VLookup to pull information from another worksheet and that working fine. And when I get that information I am ranking it. Here is my problem... Some of the data cells that are being pulled using VLookup are blank totally blank so when I try to rank it, it say #Value!. Basically I want that blank cell to be a zero instead so that I can rank it 0 being the lowest score 3in the ranking.
View 3 Replies
View Related
Mar 11, 2013
Currently i have a button on sheet 1, that contains this VBA code
Code:
ActiveWorkbook.RefreshAll
Sheets 2 , 3 ,5 all have a MS Queries.
However I only need sheets 2 and 3 refreshed , and not 5.
At the moment it takes long to refresh all , and want to specify which sheets need to be refreshed, to make it faster for the user.
FYG, I cannot remove sheet 5, as it is required on adhoc basis.
View 2 Replies
View Related
Dec 15, 2009
I have a long complicated macro that processes a ton of data and gives the output in a new sheet. I then want to create new buttons (or some sort of user clickable triggers) on this new sheet that runs another macro.
I have got the actual adding of buttons in the sheet working, but I can't find a way to automatically assign macros to newly generated buttons during runtime. Is this even possible (or are there any clever tricks I could use to get around this?)
View 3 Replies
View Related
Jun 6, 2012
Essentially, I am working with a database for a school and up until this point, each row matches up to a student with a bunch of information on them. One of these pieces of info is their parent's names. This is a much simplified look at things, but the screenshot below is a basic version of what everything looks like:
Now, the school wants me to split up the parents names from the student's and place them in their own row. I have recorded a macro to do this where you make the active cell the "full name" column for the row you want to expand, and then run the macro. Afterwards, up to two more rows are added, with the parent's names and some data copied. Below is a screenshot of what that looks like: (yellow is the new data generated, and blue is the active cell I marked to run the macro properly)
The issue is that there are thousands of these that need to be done, and I figured there is a way to do this with a macro. The issue is that not every row has parents names to expand out.
In layman's terms, I need a macro that will look at the two columns titled "Father's Name" and "Mother's Name" on each row of the spreadsheet and then, if there is any data in both or either of them, it should set the active cell to the "Full Name" column for that row then run the macro accordingly. After that it should repeat this all the way down, skipping any where neither of the columns have text in them
In the actual spreadsheet, the columns that need to be checked are AW and AX, and the column that needs to be set to the active cell before running the macro is B.
View 5 Replies
View Related
Apr 25, 2007
i need to make a macro that takes workbooks or files and
runs them through another macro. i already have the 2nd macro
done and it is working perfectly i just need to know how to make the one
that finds the other files and runs them all through the macro i already made. My boss said that he will have about 150-200 files to run through this macro.
View 9 Replies
View Related
Nov 28, 2009
I can't seem to find an answer for this, but as an alternative, on Worksheet Activate the code runs and places a 1 in Range("A1") and therefore the next time the macro will not run.
This works fine for me, but just thinking if somebody who doesn't know why the one is in A1 and deletes it this macro will run again on sheet activate.
Private Sub Worksheet_Activate()
Dim LR As Long
Dim rng As Range
If Sheets("Charts").Range("A1").Value = 1 Then Exit Sub
LR = Sheets("POD").Cells(Rows.Count, "B").End(xlUp).Row
With Sheets("Charts")
.Range("I129").FormulaR1C1 = "=ROWS(R1C1:R[-128]C[-8])"
Set rng = .Range("A129").Resize(, 10)
rng.Copy rng.Resize(LR - 4)...............
View 9 Replies
View Related
Feb 5, 2008
Running Windows XP; Excel 2003
I have a fairly simply macro.
It copies certain sheets out of a workbook (for a new workbook)
Unprotect the sheets in the new workbook
Deletes a particular cell on each sheet
Unhides a sheet
Sets all of the new worksheets to normal view
Protects the new sheets
Lets the user save and name the new workbook.
All is working fine Except it will not change the new workbook from Page Break View to Normal view.
The code I'm using = Sheets("name").Activate
Activewindow.View=xlNormal
Here's the strangest part. When I run the macro from a command button, the newly created workbook retains the page break view (as is in the original).
When I run the macro line by line via F8, IT WORKS JUST FINE
View 9 Replies
View Related
Feb 15, 2008
I have created a macro in xl2000 which was working fine - although through corporate upgrades my machine has now been upgraded with xl2003 and the macro runs for a bit and then crashes on the code below, although it only highlights teh 'rnum'
rnum = ActiveCell.Row
Is there a difference between xl2000 & xl2003?
View 9 Replies
View Related
Nov 13, 2008
The code below runs on a spreadsheet that has approx 600 rows which INDEX and MATCH another spreadsheet which has approx 600 rows. I takes about 4 mins to run.
Sub QC()
Range("T1").Select
ActiveCell.FormulaR1C1 = "Compared CCCD"
Range("V4").Select
Columns("T:T").ColumnWidth = 15.29
Range("S1").Select
Selection.Copy
Range("T1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Columns("T:T").Select...................
View 9 Replies
View Related
Oct 5, 2009
I have a bunch of geographic "buckets" (17) that hold inventory. What I need to do is carefully track the inventory of each area. If at any point, this inventory runs out, there is still a possibility that some could be sold from this bucket. So, what I need to do is redistribute the volume that is sold from the sold-out bucket to all of the other buckets.
This is not linear -- i.e., any of the buckets could be out at any time so the solution is very fluid/dynamic.
Example: ...
View 9 Replies
View Related
Mar 11, 2009
I have a macro which reads data from a large number (up to 500) of books in a folder. This extracted information is subject to some fairly heavy analysis which means that the macro runs very slowly as the sheet is constantly calculating.
I would like to add some code - maybe after 'screen updating = false' - that would turn off auto calculation while the macro runs and then restore it once the macro is finished.
View 3 Replies
View Related
Jun 30, 2009
i have a button on my workbook1 that opens another workbook (lets call it workbook2) and automatically runs a macro on opening it. Once opened i have a button on workbook2 to close itself. I then go back to see workbook1. This all works but then when i click on the button to open the workbook2 again it opens but the macro does not run.
View 4 Replies
View Related
Jul 20, 2009
Is it possible to have a macro which effectively runs all the time.
For example, if the user imputs something which is wrong I want the macro to pick it up straight away with a message box.
View 13 Replies
View Related
Sep 24, 2009
I searched for this and found a few examples on splash screens, but if someone could help I would appreciate it.
Basically I have this massive macro that runs, I recorded some of it, and VBA the rest. It does a bunch of things like bringing in different spreadsheets, formatting vlookups blah blah blah... Anyway for a nice touch I was hoping that I could get a splash screen or something that will run while this macro is running in the background. How hard would this be? The macro is button driven...
View 9 Replies
View Related
Dec 17, 2009
I have a macro in my worksheet that runs as a change event on certain comment cells. This macro unprotects the worksheet, expands the merged comment cell that just change, and re-protects the worksheet. The cell expansion works great. When I re-protect the worksheet all of the cells work correctly, except the cell that was just changed. Any other "unlocked" cell in the document stays unlocked after the protection is applied, but the cell that just changed becomes locked. I need this cell to remain unlocked to allow the user to update the comments. Here is my full
View 3 Replies
View Related
Jan 11, 2007
I have a spreadsheet that is made up of single line items with sub-totals at various points going down the sheet (ie the spreadsheet is split into sections)
Each section is about 100 rows long and 40 columns wide, 10 of which are sub-totals, all using the same formula from that i enter in column A.
As i add new sections i have recorded a simple macro that copies the active cell (ie A15 for example). It then pastes into D15, F15, H15, N15, X15 and then returns to A15.
I have linked this up to ctrl X for ease of running.
I have around 500 section totals to "ctrl X", per spreadsheet and 10 spreadsheets to do in total. I have firstly filtered all the line items (rows) out to leave me just the sub-totals to [ctrl x] [arrow down] [ctrl x] [arrow down] [ctrl x] etc etc etc....
Is there anyway to automate this process, i have tried recording another macro of me [ctrl x] [arrow down] about 30 times, but when i run it, it pastes on the hidden rows, not just on what you see on the screen. Is there a bit of code i can enter so it only sees what is visible.??
View 9 Replies
View Related
Sep 11, 2006
I have a peice of code which opens up a number of Workbooks (200+) and updates a series of control tables in each. Given our security etc environment, links and external references etc are not possible. The target files must all be standalone and self-sufficient.
The problem I have is that when I run the procedure in question in the usual way, the procedure simply terminates after the first file is opened. No error messages, no distress - it just stops. I have put debugging calls all around the "Workbook.Open" call, and it simply doesn't make it out of the call. There is no Auto_Open code in the workbooks being opened and (as I indicated above) no external links, references or function calls.
What's weird is that if I step through the procedure in the Command Debugger, everything works fine. Even weider, if I complete step-by-step processing on the first target file then I can press "Play" and the code will complete execution and process all the remaining files without error.
I have rebuilt/recreated/re-ordered the target files and even moved them to a different volume.
If anyone has seen this before, or has any idea what the cause may be, or even just a wild idea, I'd love to hear it.
Code segment attached.
*
'*** Process each file in the list provided
'*
For intCounter = 1 To intWBS_Files
Call Debug_Msg("Opening WBS File")
Application.EnableEvents = False
Set wbkThis_WkBk = Application.Workbooks.Open(strWBS_Files(intCounter), 0, False)
Application.EnableEvents = True
Call Debug_Msg(("Opened WBS File:" & Chr(13) & strWBS_Files(intCounter)))
If (wbkThis_WkBk Is Nothing) Then
Call Write_Error_Record("File Open Failed", strWBS_Files(intCounter))
Else
Code continues.....
View 6 Replies
View Related
Nov 20, 2006
I have a button. When pressed, it runs a macro. Instead, after pressing the button, I would like the user to confirm to run the macro and display some info about it. This is to make sure the user does not accidentally run the wrong macro (button). I just need a prompt box, with a line info, and the two choices YES and NO. If NO is selected, nothing happens. If YES is selected, macro continues.
View 6 Replies
View Related
Nov 29, 2006
I got a code that makes an animated userform popup (web browser in userform). that works smoothly. but, when I have that code before two more codes. The userform does show, but the animation does not. Until all the following two codes are finished running. The purpose was to have the animation running while the two codes are being processed.
Main Code: Code with 3 different codes.
Private Sub cmdAdd_Click()
Dim iRow As Long
If Sheets("LookupLists"). Range("N2").Value = "EXACT" Then
Application. ScreenUpdating = False
' Loading user form popup
Call ShowFrm
Call CopyEmplInfo
End If
Call MergeCells
End Sub
View 5 Replies
View Related
Apr 6, 2007
This macro ran fine until I started using Offset on ranges to have them extend. The macro replaces "L" with blanks but does not go on to delete the rows. The name "Type" refers to =Offset(Mem05!$A$2,0,0, CountA(Mem05!$A$2:$A$270),10)
Relevant part of Macro
wb06.Activate
Application.Goto Reference:="Type"
Selection.Replace What:="L", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveSheet.UsedRange
Is it using Offset that could be causing this error?
View 6 Replies
View Related
Mar 7, 2008
I have a Worksheet_Calculate Macro running in my workbook. I'd like to disable it temporarily when running another macro because its causing excel to run sluggishly.
View 3 Replies
View Related
Mar 16, 2007
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
View 2 Replies
View Related
Jul 31, 2014
Just to see how calculations were working out, I was trying to get a macro to scroll down the window as it calculated data.
Sadly, ActiveWindow.SmallScroll Down:=2 was too fast and =1 was too slow!
That's the only command I know to get this to work.
demonstration of a different command. Any way to get the window to scroll automatically to the cell which has just had information inserted into it?
Here's the VBA:
Sub CustomerCategory()
Dim Rng As Range
Dim Dn As Range
[Code]....
View 2 Replies
View Related