Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2010, 10:30 AM
Registered User
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Speed up my VB code

Anyone knows how I could optimize and speed up my code?

Code:
Sub FindFirma()
Dim Firma As String, Vgrp As String
Dim Stext As Range 'SøkeText
Dim StextRes As String
Dim Celle As Integer, antallCeller As Integer
Dim Line, Linegrp As Integer

'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Line = 2
Linegrp = 2

antallCeller = Range("g2:g2000").CurrentRegion.Rows.Count - 1
While Sheets("Grupper").Cells(Linegrp, 1) <> ""
    If Sheets("Grupper").Cells(Linegrp, 1) <> "" Then
        Firma = Sheets("Grupper").Cells(Linegrp, 1)
        Vgrp = Sheets("Grupper").Cells(Linegrp, 2)
    End If

    With Sheet1.Range("g2:g2000")
        Set Stext = .Find(UCase(Firma))
        If Not Stext Is Nothing Then
            StextRes = Stext.Value
            For Celle = 1 To antallCeller
                Stext.Offset(0, 3).Value = Vgrp
                Set Stext = .FindNext(Stext)
            Next Celle
        End If
    
    End With

        Linegrp = Linegrp + 1
    Wend
    Set Stext = Nothing

'Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
ActiveWorkbook.Save

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Speed up code - looping and copy / paste vba_user Excel VBA 6 March 23rd, 2011 05:27 PM
vb code that show cpu information such as cpu speed girl333 Visual Studio 2005 1 January 8th, 2010 04:39 PM
speed up slow Perl code with SQL statements crmpicco Perl 3 May 11th, 2007 05:21 AM
Speed of VB for number-crunching james gold Beginning VB 6 3 January 27th, 2005 12:59 PM
How to speed up looping ADO code? llowwelll Pro VB Databases 7 October 24th, 2004 11:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.