My workbook contains several worksheets with queries to external SQL Server database. All queries use background updates. Each query uses a parameter for the SQL query string. The parameter value is obtained from E2 Reports!B4. Manually changing this cell returns results on worksheet Job Summary in range("A6:K6"). This works great!Worksheet Order Details contains a list of job numbers in column B.
I wrote a VBA sub that loops through these jobs, changing E2 Reports!B4 for each job. I then call the Application.RefreshAll function. Finally, I copy "Job Summary!A6:K6" to a row on worksheet Order Summary. If the next job is the same order, I copy with a paste special to add the results.The problem occurs when running the VBA sub. If I step through the code, waiting for the RefreshAll function to finish, the correct values are returned. If I step through fast, without waiting for the RefreshAll, the values for some jobs are copies of the previous job, but other jobs are correct. If I hold the F8 key down or hit the F5 key, all values are the same as the first job.I've tried DoEvents, turning off screen updates, and turning off background updates.
Private Sub
Worksheet_FollowHyperlink(ByVal Target As Hyperlink) If Target.Name = "Order Summary" Then ' rj references position on Job Summary sheet Dim rj As Integer ' ro references position on Order Summary sheet Dim ro As Integer rj = 6 ro = 6 ' clear all rows Sheets("Order Summary").Range("a6:a65536").EntireRow.Clear Application.CutCopyMode = False ' turn off screen updating to avoid flicker..........................................
I don't know what exactly is happening, but every step of the macro is happening every 1 second. Literally, the BPM is 60. It will execute a step in the macro every second, when in other macro's i've made, it zips right through as if it was on fast forward.
Id like to have a running total of each sailors inspection results. So if he's had 5 outstandings, 10 sats, and 3 fails during his 18 week course, it will display this at the end of his row. Mind you, its a class of 30 for 18 weeks so there are a ton of cells. I tried multiple check box macros which assign them great but cant total the selections. Same with selection buttons.
I'm trying to run a loop that doesn't go through every value between the lower and upper bounds so am using Step at the end of the For line:
For j = 0 To s Step loop_step 'Does stuff in here - not relevant Next j
The amount that is being stepped through is set as a variable previously - called loop_step, and works fine for small values (e.g. stepping through 10 at a time) but comes up with an error for 1000. I haven't checked how large the value needs to be before it creates an error, but I was wondering if anyone knew if there's a limit on the number you can step through? Otherwise I have no idea what's causing this problem!
I get a report that I have to manually edit everyday. I've done some VBA, but not sure where to start with this one.
The attachment has two sheets, first is what I get and the second is what I want. I'll explain the process i have to go thru now and maybe I can get some help to automate it.
First -Add the tech number to the first column for each job for each tech. 7988 us the first tech number.
-Then delete every row that isn't a job. -Add a column with the install date.(report data near the top.) -Add a column and populate it with the system, which is the sheet name. Thats why its example.
I have written this code to change the colour of a row of cells to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”: This is the main workbook into which are pulled values from three others. I then want it to open one of the subsidiary workbooks, that feeds the information, to change the same job row to bright green and to change the cell contents of cell(Row, 15) from “L” to “F”. Then I want to save the changes and return to the main sheet: - The ActiveCell contains the Job Number.
Option Explicit Public rw As Integer Public Col As Integer Public Job As String Public JobNo As String Public RowNo As Integer Public wName As String Public times As Integer Public Pips As String Public Nicolas As String Public Cindys As String Public wb
Sub FinishedinOfficeCindy() . rw = ActiveCell.Row JobNo = ActiveCell Col = ActiveCell.Column If Col 1 Then Check that the correct MsgBox "Please choose the Job Number first"column is selected and Exit SubThat the workbook is End Ifthe correct one If Cells(rw, 14) "Cindy" Then MsgBox "Wrong Secretary Chosen - whoops!" Exit Sub End If
All works perfectly when I step through it but, when it is activated (Ctrl+Shift+C) it opens the other workbook and then seems to end? I even tried putting in delays to see if they would help but they didn’t.
I have a simple calculation - Say 0-6. What i need to do is, if the value is <7 place a 10 in the cell, or if the the value is <12 place a 5 in the cell, or, lastly if the value is <21.5 place a 0 in the cell. Is this at all possible - as i can only do it with conditional formatting using colours at present
Is there a way to loop through a range of numbers, pick the first 24 columns, do some kind of caclulation for each column and row, the start again on column 25 for another 24 columns, perform the same calculation, go to the next set of 24 columns, etc?
I have tried using, for example, AVERAGE(OFFSET(range,0,0,24,24) and that correctly returns the average for the first 24 columns (range being the range of data I am using like D366:HK389). However, unless I manually change the starting column for the next set, it doesn't return the correct result. I have attached a sample data spreadsheet. There are 9 Locations in the spreadsheet where each Location contains a 24x24 matrix.
I am having trouble with the code for this stepped scale rebate structure
$0 TO $50,000 NET PURCHASES=NO REBATE ISSUED $50,001 TO $150,000=5% OF NET PURCHASES $150,001 TO $1,000,000=8% OF NET PURCHASES $1,000,001 TO $2,000,000=9% OF NET PURCHASES $2,000,001 AND OVER=10% OF NET PURCHASES
I have the forumula for retro active to 50,000 =IF(O77<50001,"0",IF(O77<=150000,O77*5%,IF(O77<=1000000,O77*8%,IF(O77<=2000000,O77*9%,IF(O77>2000001,O77*10%,)))))
If the customer did 2.5 million. I need a formula that will multiply the first 150,000 by 5%, the next 849,999 @ 8%, the next 999,999 @ 9%, and the remaining 500,000 2 10%. I was thinking of using a min/max function.
While I try to create a sub - autofilter A column and select the...
- first entry (but not as a unique item, as data may changes weekly) once 1st item filtered - I'd do some function: sum weekly results, and keep only one row with the filtered item (paste special/delete rows)
- than step on next entry and do the same as before
- take these steps till the end of autofilter list, than remove autofilter.
.. with this action, I'd get the sum value of my weekly forecast on each individual items.
I have a macro in one file which uses an input box where the user types in a subcontractor code to retrieve address and contact details from another file.
If the user inputs the incorrect subcontractor code, an error message box pops up. Currently the user then has to select a button in the original file to restart the macro at the input box stage.
What I want to happen is when ok is selected on the error message, to return to the input box so in my macro below where the error message says "An error occurred - you asked for a subcontractor that does not exist. Please try again." and the user selects OK, I would like it to return to the 'Enter the Subcontractor line and the "Please enter the Subcontractor code" input box reappears.
My vb code currently creates a new sheet via "Sheets.add". This new sheet has the default name of "sheet1" which I rename as "tempSheet". I then populate tempSheet with data, save as a CVS file and then I remove tempSheet.
If I stay in my workbook and try to execute the code again, the default name of the sheet it now creates is "sheet2" and not "sheet1" - this is a problem becuase my code is trying to rename "sheet1" "tempSheet" and of course it cant.
The following code was working for me and now no longer works. Also, it works when I step through but not when I run it normally (it stops at the line imeediately following this line:
OrigWB.Sheets("PP&E").Move after:=DestWB.Sheets(DestWB.Sheets.Count) ) regardless of what code it is - even if it is only a message box.
The error message is code execution has been interupted.
****************** Sub PPEMerge() Application.ScreenUpdating = False Application.DisplayAlerts = False Application.StatusBar = "Merging..." 'retrieve source docs: 'PP&E sheets from sec packages 'system beginning and ending balances
I don't understand the relationships that are happening and what the final value would be if for example the PT was Red. I'm confused and was curious how four lines could all equal different values(highlighted).
UpUserPaint = UCase(RegPaint.Value) Dim icount As Integer LenRegPaint = Len(RegPaint.Value)
For icount = 1 To LenRegPaint ValPAint = ValPAint + Asc(Mid(UpUserPaint, icount, 1)) Next icount
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
I am trying to create a floating bridge bar chart.
Here is my data and I will try to describe as accurately as I can.
FY 2004 operating margin = 14.6% (while FY 2005 and FY 2006 = 11.2% => So the difference is 340bps)
The "bridge" back to 14.6% = 90 basis points for Jimmy'Z, 30 basis points for stock option expense, 30 bps for marketing -- that's 150 bps of the 340 and I'm trying to quantify the rest of the bridge but is there a way to show this in excel with floating bars - that is to say the 14.6% bar will touch the axis but the other 3 data points are not touching the X axis but are in the air in a step formation... ?
I am trying to automatically increment a cell value then print the sheet. I need it to increment up to 220, or possible higher, and then print at each increment; 1,2,3,etc. as opposed to typing 1 then print, 2 then print, 3 then print...etc. Can this be done with a macro? I've attached a file if you want to view it (cell J2 of "NEW PART ENTRY" sheet).
I'm trying to produce step charts like Andy Pope does on his web site using the area chart method. http://www.andypope.info/charts/stepchart.htm. This involves duplicating each of the values in each data series, which is tedious if there are a lot of points. Plus the fact that the area series is offset by 1 from the axis series. Can anyone think of a formula to do this? There are plenty of posts here about deleting duplicates, but I couldn't find much about creating duplicates. I can duplicate row numbers using =CEILING(ROW(),2)/2
I got a formula from this forum to eliminate duplicate records in a array from 1 column in database. Now I would like to take it one step further and filter out records in the array that do not meet the criteria of being in a particular "Zone" selected by the user by clicking on a ComboBox from cell "AA18".
My spreadsheet has a grouped graphic that I need to repeat in a variable number of rows. I wrote a macro that copies the grouped graphic from above and pastes and positions it in the newly inserted row.
It works great when I use F8 to step thru, but if I try to actually run the macro, I get an "Paste Method of worksheet class failed." error.
Sub InsertEmployees() Range("B18").Select Selection.EntireRow.Copy Selection.EntireRow.Insert Shift:=xlDown ActiveSheet.Shapes("Group 129").Copy Application.CutCopyMode = False ActiveSheet.Paste End Sub