Loop Vs. Simple Function, Huge Difference In Speed

Feb 21, 2010

I have a problem with one of my loops, it takes about 17 seconds to do the job of calculating a simple moving average for 200 periods on 20,000 rows. However, if I do the "FillDown" function for the same type of average, it takes 1 second.

Here is the code for the loop:

View 9 Replies


ADVERTISEMENT

How Can I Speed Up My Loop

Mar 4, 2010

I will attach a sample of the data when I figure out how to. The original data takes about 8 or 9 second to delete the lines.

Code: ...

View 9 Replies View Related

Speed Up Loop

Apr 27, 2007

I required to do some Monte Carlo analysis for 1000000 simulation. I have managed to find some free code, however, the time it took to run 1000000 >30min. Is that normal? The code that it took the longest to run is following:

For i = 1 To number_of_trials
Application.Calculate
For j = 1 To number_of_formulas
runs(j, i) = sel. Cells(1, 1 + j)
Next j
Next i

Is there any way I can implove this code to make it run faster? I have already tried Application. ScreenUpdating = False

View 5 Replies View Related

Speed Up Nested Loop

Jul 20, 2006

how to speed up the following loop? It takes about 40 seconds.

Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim x As Integer
Dim y As Integer
Dim Snominaloc As Double
Dim Scs As Double
Dim Sirating As String
Dim Mnominaloc As Range
Dim Mcs As Range
Dim Mirating As Range
Dim Mcbrating As Range

Set Mnominaloc = Worksheets("Parameters").Range("b10")
Set Mcs = Worksheets("Parameters").Range("b22")
Set Mirating = Worksheets("Parameters").Range("b12")
Set Mcbrating = Worksheets("EL").Range("b33")......................

View 2 Replies View Related

Improve Loop, Copy Speed

Aug 18, 2007

I have a large worksheet (Sheet1) containing approximately 15,000 records (15,000 rows x 21 columns). I need to search through all these records, and manually decide whether a record should be copied onto another worksheet (Sheet2) or not. The code I have written works very well (as far as I can tell), but it is extremely slow (the searching takes forever).

The code is as follows:

Sub SearchAndCopy()
Dim SearchRow As Long
Dim LastRow As Long
Dim SearchColumn As Long
Dim LastColumn As Long
Dim CopyToRow As Long
Dim SearchString As String
Dim Found As Boolean
Dim Response As Integer
On Error Goto Err_Execute
Found = False
'Fetch Search Term
Sheets("Sheet2").Select
SearchString = LCase( Range("F3").Text)......................

View 3 Replies View Related

Skipping Blank Cells To Speed Up Loop?

May 14, 2014

I have a macro I run on thousands of rows of data which occasionally has incorrect line breaks that need to be brought up to the previous row. The macro works perfectly, however I'm trying to speed it up by skipping rows that do not need processing.

The macro inserts a check in column AQ to see if column A meets certain criteria. If it does not, "False" is entered in AQ, indicating the need for processing. As it runs now, the loop steps through each row of AQ to see if it needs further action.

I am trying to come up with a way for it to automatically just jump to "False" instances, skipping sometimes thousands of rows of blank cells that need no processing.

[Code] ......

View 12 Replies View Related

Simple Loop To Get Value

Sep 27, 2008


I just like to do a simple loop but canīt seam to work it out.

I like to loop through column F and on the last cell or the first empty cell I like to get the sum.

how that works? I only find samples which donīt seam to help me much.

Also I would like to know a code to select all cells and rows and copy it into a different worksheet. Like cut and paste with vba.

View 9 Replies View Related

Cell To Cell Movement Speed Difference?

Mar 21, 2013

I've been facing a strange issue relating to Cell to Cell movement speed using arrow keys. I've two laptops which have similar specifications and operating systems. In one laptop, the movement speed, when I continuously keep any of the arrow keys pressed for some time, is very very high as compared to the other laptop. Did try to search a lot about increasing the speed of cell to cell movement with arrow keys but was not successful.

The speed difference is so high that it affects the efficiency at workplace as the movement is so fast that I navigate through the tables very quickly and easily and complete my task much earlier than on the other laptop.

View 2 Replies View Related

Using Add-in For User Defined Function - Speed

Oct 24, 2006

I just hit F5 and use it in Excel with no problem. This time a person who developed the function had me install it as Add-In. I do not know if it is supposed to give any advantages (versus simply typing function in VBE window + activating it by hitting F5 key), but the function works extremely slowly. Is this Add-In

View 6 Replies View Related

VBA Simple Right Function

Mar 31, 2008

Is there any reason why this wouldn't work in Excel 2007 despite working fine in 2003?

.Range("C2:C15132") = Right(.Range("C2:C15132"), 7)

View 9 Replies View Related

Simple IF Function

Aug 18, 2008

If Channel A = Channel B, only fill "Primary Channel" (A or B)

If the Revenue A is bigger than Revenue B then take the Channel A as primary and secondary channel column as Channel B

if the Revenue B is bigger than Revenue A then take the Channel B as primary and Channel A as secondary

Sample File

[url]

View 9 Replies View Related

Simple Conditional Addition Function

Mar 27, 2009

I imagine this is a simple conditional SUMIF function. I'd like a cell to add values in e.g. column "d" when that row meets certain criterion in column "a".

In other words, I have a column that has times recorded in minutes, and another that says a person's name which correlates with the times. I'd like a cell on another sheet to give a total sum of minutes for each person.

Ideally, part of the function would translate the minute count into hours/minutes, but I think I can figure out how to do that by changing the format in the cell...

View 6 Replies View Related

Create A Macro From This Simple Search Function

Aug 24, 2009

I am using excel 2007 for database of a large e-commerce site.
I am creating search-able attributes from keywords found in description, title and meta-data columns.

I am using the following function in "column X" to search 4 columns (see formula) for specific music styles.

View 6 Replies View Related

Simple Function For Calculating Number Of Months Between 2 Dates

Jun 22, 2012

Is there a simple function for calculating the number of months between 2 dates.

Eg 1/5/2012 - 8/9/2020

View 1 Replies View Related

Difference Between Function And Method

Jun 13, 2008

I was browsing the Microsoft Office Excel 2003 Visual Basic Reference helpfile and noticed a paragraph in the section Concepts Events, Worksheet Functions, and ShapesUsing Microsoft Excel Worksheet Functions in Visual Basic where it mentions the use of the InputBox method instead of the InputBox function to perform type checking. In VBA, what is the difference between a method and function? And when would I use one or the other?

The link to the helpfile I was looking at is here:
[url]

View 5 Replies View Related

Loop Function In VBA?

Jun 30, 2014

I am attempting to loop this function until it finds the next empty row in column C.

Private Sub Workbook_Open()

Range("C2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-1]+30)"
Range("C3").Select
End Sub

I have a feeling this is an extremely basic and easy task and I am perhaps, overthinking the code?

View 3 Replies View Related

Do While Loop With If Function

Jul 16, 2009

I am trying to "reverse the scoring" in a selected row of data. that is if the respondent selected 1 (on a scale of 1-4) I would like it to be replaced with 4.

I have done up this code (which might be pretty messy) but I always end up with Compile error: Loop without do.

Sub ExecuteConversionP2()
'Checks to see if the macro has already been run
Sheets("Sheet name").Cells(72, 3) = Sheets("Sheet name").Cells(72, 3) + 1
If Sheets("Sheet name").Cells(72, 3) > 1 Then
Exit Sub
'if it has already been run the cell C72 will have a number in it and it will exit
Else
Sheets("Sheet name").Select

'This is where I want the loop to start
Range("D76").Select
Do While ActiveCell.Value ""...........

View 9 Replies View Related

How To Go End Of Huge Data Range

Mar 31, 2014

use CTRL+ Navigation Arrow Key on keyboard i.e. if you wanna go to the last Non-Blank row in a column press CTRL+Down Arrow key if your range contains empty cells then use this shortcut SHIFT+CTRL+Arrow key

if you wanna Get the Value of cell in a column you can use this formula

=INDIRECT("A"&COUNTA(A:A))

This formula will work only if there is no Blank Cell in the range.

View 1 Replies View Related

How Do I Create A HUGE Table?

Oct 26, 2008

I have to create a 12 row 14 column table which will be printed out and put onto a (around) 20 by 20 poster board...so it has to be HUGEEEEEE. How do I do this, all the boxes inside the table I want to have control of meaning size and stuff. I will have to write in all boxes.

P.S: Yes. I know you guys prolly think im a idiot but this is my first time and my due date is appraoching fast, if anyone could help that would be great.

View 7 Replies View Related

File That Is 50mb And I Don't Know Why It Is That Huge

Jan 14, 2005

I have an excel file that is 50mb and I don't know why it is that huge. I did not create this file and was asked to look at it and figure out why it takes 10 minutes to open?

There is 3 tabs and very little data. How can it be so huge?

View 9 Replies View Related

HUGE List Filtering

Sep 19, 2008

I'm working out some vba script, that could filter up to 300,000 rows long list.

here is sample from that list:

1000999999027FRESH PASTA FETTUCINE WITH TOM102002P N0809100000035000000012810000000+0000000+ 0000000000000000+0203001896409
2000999999027020300189640900000000000005740200070063
1000999999027FRESH PASTA FETTUCINE WITH SPI102002P N0809100000025000000015700000100+0000000+ 0000000000000000+0203001896454
20009999990270203001896454000000000000057010180265125740200070070

As you can see, the rows are starting with 1000 and 2000. And that would be the criteria.

I'm importing the loooooong list file onto sheet1, and i'd like to sort the list so it puts all the codes starting with 1000 onto sheet2 and rows starting with 2000 onto sheet 3.
With regular filtering mode it's impossible and keeps giving errors.
I know it's possible, but i can't figure it out anymore.

I was thinking about to make script that would copy one row from sheet to sheet and loop it. But my mind just crashes doing that.

View 9 Replies View Related

Macro Loop With Match Function

Apr 1, 2009

I tried to create a macro that compares two columns using a match function. The macro adds the macro function to the first cell and I double clicked the bottom right of the cell to have the formula auto fill down the column.

I noticed that the macro records the exact number of rows when you perform the auto fill or fill series. Now if I add another couple rows to the sheet, the step to auto fill all the cells in the column it stops before the bottom of the column.

I have been searching for a way to make sure the formula is placed in all the cells. I have been learning about loops but am having a problem building it.

View 9 Replies View Related

Loop Through Directories & Files With Dir Function

Jan 18, 2008

I am trying to do is loop through a series of directories under a target directory. When a directory is found, it looks within that directory and finds any .xls files, loops through those and copies/pastes them to the new target directory. I have managed to get it to work only on the first iteration of the loop through the directories, then it crashes. The error code is "Invalid Procedure Call or Argument." Here's the

If valFilePath = True Then
MsgBox (msg)
Else
'Search for directories within source directory
strDir = Dir(ebsSource & "", vbDirectory)
'If a file has been found
Do While strDir <> ""
If strDir <> "." And strDir <> ".." Then
strFile = Dir(ebsSource & "" & strDir & "" & "*.xls")
Do While strFile <> ""
'Copy .xls files and paste in destination
copySource = ebsSource & "" & strDir & "" & strFile
copyDestination = ebsDestination & "" & strDir & "" & strFile
FileCopy copySource, copyDestination
strFile = Dir
Loop
End If
'Crashes here after looping through the first iteration of Excel files
strDir = Dir
Loop

View 2 Replies View Related

Best Method To Sort Huge Sheet

Aug 7, 2012

Is the a more efficient way of sorting a huge sheet (One Column only)? Currently, I use the below code and sometimes it throws an error (due to insufficient memory/ cannot undo this step)

VB:
Sub sort1()
Rows("1:1").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.sort.SortFields.Clear

[Code] .....

View 3 Replies View Related

Working With Huge Data But Getting Hanged

Apr 27, 2009

When i'm working with huge data on excel say for exam 50000 records and about 25 to 30 columns, everytime i use any formaula and while saving it the file is not responding, what ever the formula like vlookup, countif, converting in values applying filters and removing filters and with that whatever the changes i do that is not seen next time when i open file.

View 9 Replies View Related

Output Huge Number Of Permutations

Jan 8, 2008

I have several columns of info on my worksheet. I want to output a list of all possible permutations from this worksheet (not the number of permutations but the actual permutations themselves).

View 9 Replies View Related

Average With Huge List Of Criteria

Jun 25, 2008

I'm currently stuck with the following problem. I have a fairly large database with 10,000+ companies (in the rows) over 10 years (in the columns). I want to aggregate industry averages of a financial item in so-called SIC codes (there are approx. 1,000 different 4-digit SIC codes).
I've been using the daverage function, which works for one criterium (e.g. SIC = 0100) but not for the entire range of criteria. Does this mean I'll have to manually adjust every daverage function for every single SIC code? Or can this process be automated in some way?

Attached is a simplified version of my database file.

View 9 Replies View Related

Function VLOOKUP At VBA Program Inside A FOR Loop

Apr 17, 2009

I want to use the function VLOOKUP at my VBA program inside a FOR Loop

View 3 Replies View Related

Recursive Loop Function Not Returning Result

Sep 20, 2007

I'm currently working on a program in which some sort of recursive looping seems logical.

The relevant part of the code I've currently written looks like this:

Sub hello()

Dim Max_stream As Integer
Dim j, jj As Integer
Dim P_sum, P_min As Double
Dim antal_in, antal_ut, rad_in, rad_ut, ut1, ut2 As Integer

Application. ScreenUpdating = False
Max_stream = WorksheetFunction.Max(Worksheets("Data"). Range("B65536").End(xlUp).Value)

For j = 1 To Max_stream

The problem with the code above is the last If, in which the function "rekursivloop" calls itself. I don't know if this type of formulation is correct, but for the cases the If condition is TRUE (ie ut1 <> ""), the function does not return any answer. Does anyone see an error in the logic or have some example for how to write similar recursive loops?

View 8 Replies View Related

Huge Data File Delete All Rows With X Value?

Jul 21, 2014

I have a huge data file. I would like to have excel automatically delete all rows with the value of 7 in column b. Can I do this without manually selecting all of the rows (I can sort by that value, but there are 120,000 rows).

View 6 Replies View Related







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