Running Code On Specific Worksheets
Dec 4, 2009
Let's say I have 6 Worksheets in my Workbook with the following names:
Sheeta1
Sheeta2
Sheeta3
Sheetb1
Sheetb2
Sheetb3
And I have three Subs that I want to run, one Sub for two specific Worksheets.
How could I code my Subs so that the first Sub runs on Sheeta1 and Sheetb1, the second Sub runs on Sheeta2 and Sheetb2, and the last Sub runs on Sheeta3 and Sheetb3?
As you can see, the 1, 2 and 3 in the Worksheet names are what links the Subs to the Worksheet.
View 9 Replies
ADVERTISEMENT
Jun 27, 2014
I have the following code, I have it running to just work on Sheet 2 but I would like it to be able to run on mulitple sheets, not all but a range like from Sheet2:Sheet30.
[Code]........
View 12 Replies
View Related
Jan 27, 2010
I have a workbook with multiple worksheets. On some of those worksheets a have merged cells, so in order to paste new data I need to unmerge them first. Below is the code that I wrote for it. However it doesn’t work and returns “Run-time error '1004': Application-defined or object-defined error”. I looked at this post List Maximum Value From Each Worksheet and tried adding With – End With, but it failed too. As far as I understood the problem is that the Worksheets/Sheets object does not support UnMerge property, but I may be wrong. If I add ws.Activate line (test2) everything works fine.
However I was wondering if there is a way to do it WITHOUT activating the worksheets.
Sub test1()
Dim i As Integer, ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Select Case ws.Name
Case "5 - Top Network Facilities", _
"5b - Top Arb Facilities"
For i = 0 To 9
ws.Range(Cells(2 + i * 5, 1), _
Cells(6 + i * 5, 1)).UnMerge
Next i
Case Else
End Select
Next ws
End Sub
View 4 Replies
View Related
Apr 21, 2006
I am trying to run a macro once a particular word shows up in the combo box. now in my chase i could try to use VBA code to run the macros such that once the arrow is used in the combobox to select a certain word a particular macro labled the same name as the word chosen would run.
View 5 Replies
View Related
May 12, 2009
I am dealing with several very large spreadsheets using VBA to do various things. I found that my code worked well, but was taking a long time to run. The biggest time consumer was my use of the AutoFilter features. I have since turned calculations to manual before my code runs and set it back to auto when my code is done running. What are the potential consequences of my turning calculations to manual and then back to auto?
View 2 Replies
View Related
Oct 7, 2007
I have a macro that I would like to run on every worksheet in my book (over 100 sheets wide). As it takes about 20 secs to run on each sheet, and I don't want to click from sheet to sheet, how can I make it run on every sheet in the book? And no, they aren't named sequentially, either alphabetically or numerically.
is there a function in Excel to return the number of sheets in a book?
View 9 Replies
View Related
Dec 20, 2013
I am seeking code that will go to Sheet 4 (named "Extract"), copy a1:a5 and return to the active cell the macro was launched from and copy the values in.
The challenge I am having is how to get the code to return back to the cell it was launched from since I want the flexibility to use this macro in multiple tabs/sheets to copy the info into ANY selected cell within ANY sheet. As it is now, I have to go change the sheet name each time for the then active sheet.
I've attempted to insert a generic worksheet reference, however I end up with a debug issue.
Sub Macro10()
'
' Macro10 Macro
[Code].....
View 2 Replies
View Related
Apr 8, 2007
I have a workbook that contains a worksheet called CALC , in column A of this worksheet I have a list of other worksheets that I would like to run a macro on.
Would it be possible to set up some code that would select the worksheet at the top of the list, perform a macro then select the next worksheet in the list and carry out the macro on that sheet until all worksheets that appear in the list have been updated.
View 9 Replies
View Related
Jun 5, 2009
I want to know if I can schedule a macro to run at specific times?
If so would 6 requests at the same time slow excel down?
View 6 Replies
View Related
Jun 24, 2006
I have a module which runs behind a command button which creates a table and outputs it to an excel workbook. Is it possible to cause this module to execute at a specified time, say 9.00 pm or when the database is closed. It is not necessarily the case that the database is closed every day.
View 9 Replies
View Related
Jun 5, 2007
I have a cell B6 which I would like the amount to change with each entry I make. I have B4 which has constant amount, B8-B40 will have new entries and D8-D40 new entries. I had a function that had number 1 B8:B40 number 2 -D8:40 number 3 +B4. the function total in grey box is correct but when I press enter the cell in B6 says value and doesn't change to correct amount. Basically I have a balance in B6 that I want to change auomaticlly when I enter data in B8,D8 one day, then the next day, which B9, D9, etc..
View 5 Replies
View Related
Nov 30, 2006
This is bizarre - over the last year or so, on two machines (one Win98SE/Off2K, the other Win2KSP4/Off2K3), very occasionally a change I've made to Excel/VBA code has been ignored (eg to add a MSGBOX call) - even after I've restarted Excel. The workaround is to add a blank line and remove it again in the actual code module, but its both annoying and intriguing,
View 4 Replies
View Related
Nov 6, 2008
My code runs so slow! The sheet only has 233 rows and 6 of them are not in the loop.
View 6 Replies
View Related
Oct 4, 2008
I need a message box with information before the code run. Yes - code run, No - exit code.
View 9 Replies
View Related
Sep 28, 2009
I have written some code intended to automatically clear a cell when data appears in it from an external source. In one spreadsheet, it seems to work exactly as expected, ie when the cell is polulated, it immediately clears the contents. In another spreadsheet, with exactly the same code, it will not automatically clear. If I put it in debug mode and step through it line by line, then it does do as expected but otherwise it won't.
View 9 Replies
View Related
Jun 29, 2007
I have used a code to find the character "-" and replace it with nothing ("") from several named worksheets across my workbook, which OzGrid helped me with before, and it worked fine. Now I've added the code into my module (at the bottom) it doesn't work. The rest of the code works fine, and it doesn't come up with any errors when I run it, but it just seems to ignore the 'find and replace' part of it.
Sub split1()
Dim fromSheet As Object
Set fromSheet = Worksheets(1)
Dim fromRow As Integer
Dim toRow As Integer
Dim lastRow As Integer
Dim errCount As Integer
Dim thisSectionName As String
Dim i As Integer ' loop counter
Dim rng As Range 'found range
Dim emptyCellAbove As Range
Dim rng1 As Range
Dim arng1 As String 'Address of 1st hit rng1
Dim ws(7) As String
Dim ii As Integer '2ND LOOP COUNTER
Dim iii As Integer '3rd Loop Counter
View 9 Replies
View Related
Jan 15, 2012
I'm trying to create a spreadsheet that uses one cell to enter a dollar amount and stores the amount entered in another cell. But I would like the input cell be zero after each entry, and the cell storing the amounts to keep a running total.
View 4 Replies
View Related
Apr 29, 2014
Attached is an example of the program. The purpose of this program is to allow someone with very little knowledge about the information to enter data. The first tab labeled "Instructions" is will have two macros assigned to the buttons at the bottom of the page. The first macro labeled "Move Data" will move data will clear data in the shaded cell on the "Entry Form" sheet and fill those cells in with '----. The second macro labeled "Generate and Save" will save a master copy of the program, save a historical copy of the program by date, and print/save a pdf copy of the "Reports" sheet.
Each one of the historical (the last 8 sheets of the program) sheet receives data from the "Entry Form" and then moves the data by date into the table for archiving purposes.
If you look at the code for the "Entry Form". I have a couple of subs. The first being Worksheet_change. the first section of this code is to force certain cells to be uppercase. This part of the code is working fine. The second part of the code is the Dim MyValues. This part is working fine also, but...
My issue is... When I run the move data macro from the "Instructions" sheet the Dim MyValues reads these as changes to the cells and wants to push the data to the historical sheets.
What I would like is an IF Statement above the Dim MyValues part of this code that stops the Dim MyValue part of the code running if those values are blank, 0, or have '---- entered into them.
Test.xlsm
View 3 Replies
View Related
Jul 13, 2009
I have placed the code I am using below. It takes values from a hidden sheet (PACTAct) and places them on a visible sheet (Email). The code moves between the two.
It works at the minute by unhiding the PACTAct sheet then at the end re-hiding it. However I don't want the user to see this sheet whilst the vba is running. Is there a way I can simply refer to the worksheet without unhiding it?
View 6 Replies
View Related
Jan 5, 2012
I have a macro, that basically runs a sub routine to count down say for example 1 min, at which time the workbook closes. However if the user opens one of the forms I would like to turn off the background timer macro. How can I do this with code? Is there code that does the opposite of 'application.run'?
View 1 Replies
View Related
Aug 2, 2006
I want to place a message in cell
Sub OutOfStockDate()
templateSheet.Range("B15").value = dataSheet.Range("G5").value
If dataSheet.Range("G5").value = "" Then
templateSheet.Range("B15").value = "There is no Out of Stock Date"
End If
End Sub
However when I run this code I get the infamous 1004 error.
View 9 Replies
View Related
Oct 19, 2007
I know how to enable/disable events using VBA code, however is there an option within excel to turn it on/off? My problem is this...
At the beginning of my code I disable events and at the end I enable it again (I need to do this to avoid being caught in a loop). However something is going wrong somewhere in my code and the code stops halfway through. I'm trying to test sections of the code, but I often inadvertently stop the code without enabling the events again. Therefore I can't get my VBA to execute again unless I close excel down and restart. This is a pain as I have to find my place in the code again!
View 5 Replies
View Related
May 9, 2008
I am writing a grading program, which during the course of functioning must run other code that has errors. I have used On Error Resume Next code to allow the program to keep functioning when it has run into errors so far. However, when a subroutine is called that calls another subroutine with incorrect parameters, I get a VBA error message pop up. Inserting On Error Resume Next directly into the other code doesn't stop this problem. I either need a way to have it skip over any call to a subroutine with improper parameters, or to check if a project can compile before grading it.
View 3 Replies
View Related
May 22, 2013
I have just written a macro to validate/clean up some data which I get on a monthly basis. Some of the columns come from a pdf file and thus excel recognises these as strings. I have written some code that would convert this string to an integer which runs fine when I step through the code. However when I run the macro from a button the number value goes from e.g. 5000 to 0.
The code is below:
VB:
Sub Condition2()
For k = 8 To LastRow
Worksheets("Bordx Format").Cells(k, i - 1).Value = CDec(Cells(k, i - 1).Value)
Next k
End Sub
View 2 Replies
View Related
Jul 18, 2014
I usually just use macros to clean up Data from non-excel sources. So I wrote a macro to do this, but the process requires a date to be added, so attempted to do this via an input box. The input box works, but the code doesn't, clicking the button to which the macro is bound spits out an error 91 (object out of bounds?) when it hits the search function right after the inputbox code. Both bits work as intended separately, so I guess it's just some moronic formatting error on my behalf.
[Code] ......
View 6 Replies
View Related
Feb 26, 2014
Two workbook, A & B. Code in B copies some data over to a sheet in workbook A.
It does this not problems if A has remained open, but if it has just been opened, I get a "subscript out of range" error at the "With Workbooks" line.
The bit in red is what I have recently added to allow workbook A to be closed unless needed. Since adding this, the debug error has emerged, even though there was no problem when workbook A remained permanently open.
View 3 Replies
View Related
Apr 4, 2009
The code opens a varying workbook with the same format as the source workbook and copies specific columns into the source workbook.
It is currently taking about 20seconds to run.
The worksheets are protected and have merged cells hence the call TestMe line.
View 13 Replies
View Related
Apr 28, 2009
I need a MsgBox that will prompt for a Yes or No response. If you answer Yes run the code below if you answer no just stop and leave me in the current sheet.
View 10 Replies
View Related
May 13, 2009
Sub SplitOut()
Dim DataSH As Worksheet, OutSH As Worksheet
Set DataSH = Sheets("Input")
DataSH.Activate
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
For Each ce In Range("D2:D" & lastrow)
Application.StatusBar = "Actioning " & ce.Row & " of " & lastrow.............
I am working on this spreadsheet that has a lot of information that will only get bigger as time goes on. I would like to organize the contents of one column into separate spreadsheets. So if I have "stacking" in one cell of that column, the whole row associated with that cell will go to a new spreadsheet labeled "stacking".
I have attached the sheet. I would like column D (Type_Code) to be organized by the words in that column. So I would have 5 or so worksheets labeled stacking, cartoner, wheel, inspection, etc. The data here is input by a machine.
View 3 Replies
View Related
Jun 9, 2009
Now..when I run any of my macros, I get the following message.. "Code Execution has been interrupted".
I'm not sure why I'm getting this message but it happens everytime I run ANY macro. Note that if I hit "Continue" every time it gives me the option, I am able to successfully run the macro, but obviously, I shouldn't have to do this.
View 5 Replies
View Related