Amend Code To Run Faster

Sep 5, 2008

I have the following code kindly supplied to me by someone else and I'd like to know if anyone can suggest any ways to speed up the running of it. It currently takes about 4 minutes to run (there are about 5000 cells to loop through)

Basically it looks for a value in Col C - works out the number of rows to fill up by searching a range in Col D - then copies value in Col C up by that number of rows.

View 10 Replies


ADVERTISEMENT

Can This Code Be Modified To Run Faster

May 30, 2009

way to bring more efficiency in this code.

I need to run this code on 100,000 rows every week and this takes hours to finish.

View 14 Replies View Related

Make Code Faster/better Best Practices

Dec 27, 2008

I have the following section of code and i am trying to make it faster. Currently when this procedure runs the screen "changes" durings its execution. Now i know i can "turn off screen updating" and this will increase speed but are there commands in the code which will prevent the screen from updating. I know activating or selecting things causes the screen to change. Also, any inputs to make this faster/better would be greatly appreciated.

View 14 Replies View Related

Faster Calculation Than SumIf Code

Nov 21, 2006

I have the following code performing SumIf and searching roughly 9,000 rows of data. Calculation takes roughly 15 seconds on the high side.

Bonus question from a rookie - This code runs well in Sheet2, but errors out on the SumIf's when placed in a module or userform. What needs to be changed for it to work outside of Sheet2?

Private Sub DistNeg_Click()

Dim BotRow As Long

Application.ScreenUpdating = False
Worksheets("Sheet2").Range("A4:E65536").ClearContents
'Copy current selected Distributor names to sheet2
Worksheets(1).Range("DIST1").Copy Destination:=Worksheets(2).Range("A4")
'Define the bottom row of distributors in this list.
BotRow = Worksheets(1).Range("DIST1").Rows.Count + 3
'Sum for PY, CY and $CHG sales. Create percentage Chg column.
Worksheets(2).Range(Cells(4, 2), Cells(BotRow, 2)).FormulaR1C1 = "=SUMIF(Sheet1!

View 9 Replies View Related

Why Is My Code So SLOW, Anyway To Make It Faster

May 3, 2009

I am only looping it through about 4 thousand records, looking for match and dups and moving it over to the other sheet, so why is my code running so slow?

I have run other programs where the records are in 40 thousand and it doesn't take as long as it is right now. Is there a way to make code run faster?

View 9 Replies View Related

Amend Code To Sort Sheets By Number

May 8, 2008

I tried this macro, written by Leith, to organize a workbook of over 100 worksheets, all named as a 3 digit number. (001, 002, 007, 004, 018, 12, etc.)

For some reason, there was no order to the sorting. Can the macro above be modified to sort my sheets in numeric order?

View 9 Replies View Related

Optimizing Macro To Run Faster - Timer Code

May 3, 2007

Here is exactly what was described:


A good place to start is to add some "timer code" in your macro. Add a small routine that saves a time value, and another routine that compares that saved value to the current time and displays the difference. At the beginning of a section of code you want to analyze, you call the first routine (which saves the start time), and then at the end of the section of code you call the second routine. In that way, you can determine which portions of your code are taking the longest time to execute. These are the code sections you then focus on, so you can figure out what they are doing that is taking so long.

This sounds like a great tool for optimization...

View 9 Replies View Related

Macro Code To Amend The Status Of Cell To Be Date?

Mar 31, 2014

I have a user form we are using to transfer data into an excel spread sheet. When transferring the date from a text field it is formatted as general, I need this to be a date format DDMMYYY. The cell needing formatting is N2

View 5 Replies View Related

Excel 2003 :: How To Amend Existing Code In Workbook

Feb 3, 2013

How to amend existing code in a workbook that is used by many different users. I am working in Excel 2003. The existing code copies data from certain cells in the active worksheet (which is password protected) into a new worksheet and saves that new worksheet to a temp folder, sends it to a particular email address using outlook and closes it, returning the user to the first workbook. You will see that it also unhides then rehides columns of the first worksheet during this process so that the user never has to see them. Problem here is that none of the users are using outlook anymore and I would prefer that this new spreadsheet that is created just be saved to the users desktop. I have found bits and pieces of what I needed on the web, but I can't seem to put it all together (I usually end up being sent to the debugger just short of having the newly created spreadsheet saved to desktop). Here is the existing code:

Private Sub CommandButton1_Click()
Range("A2:G2").Select
Selection.ClearContents[code]....

Essentially what I need to do is circumvent the whole email bit and save the spreadsheet that is created to the users desktop instead of a temp folder.

View 2 Replies View Related

Amend VBA Code To Change Mandatory Inputbox To Userform Combobox Entry

Apr 25, 2013

I have 4 columns, If column B (Ref No) is filled in, the adjacent columns, C,D and E become mandatory and an input box pops up on screen one after the other for entry into each column.

My problem is that I require a drop down list and not a input box for the final column (status). So i have created a userform with a combobox dropdown. I am having problems connecting the combobox selection to the final column, and for the selected combobox item to go into the right cell like the input box entry currently does.

Attachment 53209test743.xls

I have attached a sheet and also you can see the code below.

Code in Sheet

VB:
Public SaveVal1
Public SaveVal2
Public SaveVal3

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

[Code] .....

View 3 Replies View Related

Faster Than For Each

Apr 4, 2007

I'm using the following code to populate the columns next to the dynamic named range dataforgraph (varies in length). It works, but the problem is that it takes ages. Is there a more efficient way of doing it. It is important that it only populates the cells next to the varying dataforgraph. The avg1 and stadev1 are the same for each entry (thus constants)

For Each c In Sheet3.Range("dataforgraph")
c.Offset(0, 1) = Sheet3.Range("avg1")
c.Offset(0, 2) = Sheet3.Range("avg1") + Sheet3.Range("stadev1")
c.Offset(0, 3) = Sheet3.Range("avg1") - Sheet3.Range("stadev1")
c.Offset(0, 4) = Sheet3.Range("avg1") + 2 * Sheet3.Range("stadev1")
c.Offset(0, 5) = Sheet3.Range("avg1") - 2 * Sheet3.Range("stadev1")
Next c

View 3 Replies View Related

Amend Match For Min & > 0

Jun 8, 2009

I need to amend this formula so match only cells with min values > 0.

View 3 Replies View Related

Calculates Faster Than IF

Aug 21, 2009

I have an entire row of if statements that basically check other sheets if a number occurs. If it does then it will display "Pending Approval" ,"Open", or "Closed" depending on which sheet the # appears on .. Just wandering if their was a better formula for this..

View 7 Replies View Related

Faster (non-loop?) Way Of Doing This

Jan 22, 2009

Is there a faster (maybe a non-loop) way of doing this?

Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim Test1 As Single
Dim Test2 As Single
Dim Test3 As Single

With Sheet2

For Test1 = 33 To 52
If .Range("J" & Test1).Value = "End" Then
.Rows(Test1).Hidden = True
Else: .Rows(Test1).Hidden = False
End If
Next Test1

This causes a bit of a delay (7 seconds or so) when switching to the sheet, which is causing the user to think that excel has locked up.

View 9 Replies View Related

Amend Macro To Run Through All Sheets Except Two

Feb 5, 2009

I have found and adapted a macro (below) that searches all worksheets for a specific value (entered by the user in a specfic cell) then displays a list of hyperlinks to the matching cell locations.

I now have a couple of sheets I don't want to be included in this macro ("Master List" and "Pivot Table") but I'm really struggling to find a way of amending the macro to exclude these. I've searched and tried a couple of ways but I get errors and I think I'm not knowledgable enough to know where to put each bit of code.

View 3 Replies View Related

Amend To A Database Daily

Dec 31, 2009

I have a daily log for work that keeps track of purchases and returns among other items and I was wondering if there was a way I could have all this information get put into a log that will amend everything for each week, month and year.

View 14 Replies View Related

Amend Csv File From List

Jun 7, 2009

I have a csv file (Import.csv) containing rows similar to the following:

001032,117.5,19/09/2005,Ref1,Ref2-1,100,44100,#Sales#,,Import routine
001033,129.25,19/09/2005,Ref2,Ref2-2,110,44100,#Admin#,,Import routine
I also have a worksheet with the following list (which will grow):

Cost Centre Codes

AB1DepartmentCode2AdminADM3SalesSAL4StoresSTO5PurchasingPUR

Excel tables to the web >> Excel Jeanie HTML 4

The deprtment codes in the csv file are all contained within '#' markings.

I need a macro that will find and replace all department codes in the csv with the relevant Code from the list, and remove the '#'s. Unfortunately, some of the fields are numeric with leading zero's so I dont want to lose these by opening and re-saving the file in Excel as a csv.

The output for the above is as follows:.........................

View 9 Replies View Related

Is There Anything Faster That 'select Case'

Sep 1, 2008

Is there a way to count if there are 5 or more in a range without
using 'select case'

or not using the 'intcounter' bit bit of code?

Set Startcell = Sheets("meetingstodate").Cells(xlrow, 2)
Set Endcell = Sheets("meetingstodate").Cells(xlrow, 7)
Set rng = Range(Startcell, Endcell)

lastrow = Sheets("meetingstodate").Cells(xlrow, 2).End(xlDown).Row

For xlrow = 2 To lastrow

arr = Range(Startcell, Endcell).Value

For j = 1 To UBound(arr)

For k = 1 To UBound(arr, 2)

Select Case arr(j, k)
Case A
intcounter1 = 1
Case B .....................

View 9 Replies View Related

VBA Running Faster Than Excel

Nov 6, 2009

I have discovered a strange problem with my VBA code. After testing it on several machines, I've found no problems with my workbook until now. After being run on a rather slow Windows Vista laptop, I've found that VBA appears to be running faster than Excel, and consequently it is creating errors as VBA asks Excel to do things before it has finished a previous action. This is causing macros to fail several times in each run, though can be solved simply by pressing 'debug' and then F5 to continue the code. Is there a way to get VBA to run slower to solve this? As I can't think of any other way of doing it? I've certainly not seen it happen on any XP or Win 7 computer!

View 9 Replies View Related

Faster Way To Delete Rows

Nov 11, 2009

My spreadsheet is a contract file that includes a list of part numbers being sold. Each part number refers to a lookup table of ALL about 20,000 valid part numbers and prices. Once the contract is finalized, I want to make the contract sheet smaller by deleting all rows in the lookup table that are not required for this contract.

The following code works, but it takes more than 10 minutes to work through the complete list. I read down the lookup table. For each record in the lookup table, I call a routine that reads through an array of the part numbers that are included in this contract. If the lookup table part number IS included in the contract, I skip it. If it is NOT required, I delete it. I then return to the main lookup table and read in the next lookup table record.

This is the main routine where I progress down the big lookup table.

'Work down the Price File range from top to bottom
Set RefTableRange = DSWPrices.Range("DSWPriceRange")
RefTableIndex = 1
Application.Calculation = xlCalculationManual
While RefTableIndex < RefTableRange.Rows.Count
RefTableIndex = RefTableIndex + 1
'check if this part number is included in the contract
Call CheckRefTableRow(RefTableRange, RefTableIndex)
Wend.....................................

View 9 Replies View Related

Retrieve And Amend Records From Database

Apr 11, 2008

I am a building a database where each row represents a record. Each record has a unique identifier number.

In worksheet "Record Search and Amend", I have recorded a macro to look up the data.

The problem is once the record is retrieved I need to be able to amend the record and save it back into the database in the right row. This could be another button to initiate this action.

View 14 Replies View Related

Trying To Amend Existing SUM To Make It More Selective

Oct 27, 2009

This is a formula in an existing spreadsheet that I need to amend.

{=SUM(IF(WeekNo=2,IF(Workgroup="REASSIGN - CAP",1,0)))}

‘WeekNo2’ and ‘Workgroup’ are names defined and are offsets that define two separate columns.

I have created a new name ‘realclosetime’ and it is an offset to another column of data.

I have tried to change the existing formula so that it is not actioned if the ‘realclosetime’ is empty. It’s a date and time field and if it is not completed I don’t want to be including that row in the SUM calculation otherwise I end up with N/A’s.

View 10 Replies View Related

Faster Way Of Doing VLOOKUPs On Multiple Items?

Nov 9, 2009

Instead of doing a long long formula that is =VLOOKUP(x1,....)+VLOOKUP(x2,.....) is there a faster way of doing it in the one formula?

View 7 Replies View Related

Faster Way To Loop For Price Indexing

Dec 10, 2009

I'm trying to improve a code that Indexes a series of prices to a day (the first day of a range). I'm doing this to numerous named ranges. The code that i build takes ages to do this:

View 9 Replies View Related

How To Adjust Width Of Columns Faster

Nov 17, 2012

1. Is there a faster way to adjust the size of the columns? I had to use my mouse to stretch the column out. This can be quiet time consuming if there are 8 columns needing to adjust to the same size. ie Col A, B,I, J needs to be the same size.

2. Can Excel determine the best size for the column? Say I need a column with data saying "yes" and "no" and a column for the letter "X" only or do I have to stretch the width of the column myself?

View 1 Replies View Related

VBA - Faster Delete All Visible Cells?

Jul 23, 2013

Any way that the following code could perform faster? Unfortunately, i'm deleting 35,000 rows of data quite frequently from a filtered list. Could be up to 35 columns wide.

Code:
ls = Cells(Rows.Count, 1).End(xlUp).Row
If ls > 1 Then
Range("A2:A" & ls).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If

View 1 Replies View Related

Find Page Breaks Faster

Jul 21, 2007

I need to find row numbers of the horizontal page breaks on a sheet quickly. The only method I have found to do this is by using the HPageBreaks property, which is painfully slow.

Is there another way of doing this that's faster? Or some other manner of using HPageBreaks that improves its speed?

The scenario is that I have a macro which generates a list of items where each item is two rows long. If an item intersects a page break--one row is on one page and the 2nd row is on the next page--I want to insert a row so that the entire item is on the next page.

View 9 Replies View Related

Macro Run Faster In 2000 Than 2003

Feb 18, 2008

I have a macro which is able to run very fast in Excel 2000. Almost 5s. When i run it in Excel 2003, it takes almost 4 to 5 mins to complete. Is there any patch in 2003 i need to run the macro smoothly?

View 4 Replies View Related

Amend MAX CF Formula To Only Show The 1st Identical Number?

Dec 2, 2013

I have a conditional format which uses this format MAX($N$84:$N$94) to colour the cell containing the number but I now wish to amend this formula so that if an identical number also appears further down in the column only the first of the cells containing the identical number(s) will be coloured but none of the others,

View 4 Replies View Related

Amend Ranking Formula For Sports Results

Oct 15, 2009

I am attempting to upgrade a scoring system in excel 2003 which I use to rank wins in a sports results grid and i have to amend a formula based on a new version. The current formula in the attached part-completed worksheet Draw9 of 1 to 9, which I wish to amend, is in cells AM42:53 one of which is:

=IF(AL44="","",RANK(AL44,AL44:AL53)&CHOOSE(AND(RANK(AL44,AL44:AL53)<>{11,12,13})*MIN(4,MOD(RANK(AL44 ,AL44:AL53),10))+1,"th","st","nd","rd","th"))

I have now added an extra column of data in cell AN44:53 under “LSD” and I would like to use this to improve the accuracy of the original ranking. In other words I wish to Rank teams using the “Wins” in column AL42:53 plus the “LSD” data in columns AN44:53 and this will ensure that where teams are tied on the same number of wins then the numbers in the “LSD” column will enable a clear ranking i.e. say 3 teams on 3 wins ranked 6th = will now be ranked 6th,7th & 8th.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved