Results 1 to 8 of 8

I created a function that runs too slow! Can you help me?

Threaded View

  1. #1
    Registered User
    Join Date
    08-23-2017
    Location
    MEXICO
    MS-Off Ver
    2013
    Posts
    2

    Exclamation I created a function that runs too slow! Can you help me?

    Hi everyone!

    I just created a FUNCTION to find the column number of a cell in other BOOK depending of two variables. For 100 cells it takes 3 minutes to calculate!

    THIS IS MY CODE:
         
    Option Explicit
    
    
    Function ENCUENTRASEM(takt As Double, wagon As String) As Double
    
    Dim col As Integer
    Dim row As Integer
    Dim res As Integer
    
    Dim NumRows As Integer
    Dim NumCols As Integer
    NumRows = 370
    NumCols = 148
    
    res = -1
    For row = 8 To NumRows
        For col = 5 To NumCols
        
            If Application.Workbooks("SHM_170720_0300_TSH_CHU_Takt-Schedule_V049").Worksheets("3.TAKT SCHEDULE").Cells(row, col).Value = wagon And Application.Workbooks("SHM_170720_0300_TSH_CHU_Takt-Schedule_V049").Worksheets("3.TAKT SCHEDULE").Cells(row, 1).Value = takt Then
                res = col
                Exit For
            End If
            
        Next col
        
            If res <> -1 Then
                Exit For
            End If
    Next row
    
    ENCUENTRASEM = res
    
    End Function
    Last edited by LuisEngineer; 08-23-2017 at 07:39 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code runs slow
    By jamfz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 12:25 PM
  2. VBA runs slow locally, runs fine when connected remotely
    By jbzy324 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2015, 10:05 PM
  3. VBA Code runs too slow
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2012, 07:19 AM
  4. Replies: 1
    Last Post: 07-15-2011, 01:24 AM
  5. Spreadsheet runs slow
    By jmoffett in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2008, 02:47 PM
  6. Macro runs slow
    By Sandy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-20-2005, 12:05 PM
  7. macro runs slow
    By nanomiter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1