+ Reply to Thread
Results 1 to 15 of 15

How to Optimize This Code?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365
    Posts
    263

    Re: How to Optimize This Code?

    Quote Originally Posted by sintek View Post
    What are you actually wanting to achieve here...can you explain the process...
    Hello sintek, thanks for the interest!

    My goal is to replace all the product codes (SKU) for the category code. I have a periodic data sheet that contains all transactions identifying the client ID. The original the file has all the SKU numbers also, which can be used to identify which category it belongs. I'm not sure if this is the best way of doing it, but for my actual knowledge it suits, as I don't have much more time to study before completing this task. The only reason for selection is that it makes it easier, as each data sheet can vary on lenght and also for using 2 different worksheets.
    Pedro.

  2. #2
    Forum Contributor
    Join Date
    01-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365
    Posts
    263

    Re: How to Optimize This Code?

    I tried adapting the code to skip dates and text and it seems to have worked faster, although it still demands a couple hours. I will keep using this for now, until and if someone has any other idea that could help.

    Sub MultiFindNReplace()
    'Update 20140722
        Dim Rng        As Range
        Dim InputRng   As Range
        Dim ReplaceRng As Range
        Dim xTitleId   As String
        xTitleId = "KutoolsforExcel"
        With Application
            Set InputRng = .InputBox("Original Range ", xTitleId, Selection.Address, Type:=8)
            Set ReplaceRng = .InputBox("Replace Range :", xTitleId, Type:=8)
            .ScreenUpdating = False
            .EnableEvents = False
            .Calculation = xlCalculationManual
            For Each Rng In ReplaceRng.Columns(1).Cells
                If Not IsDate(Rng.Value) Then
                If IsNumeric(Rng.Value) Then
                    InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, Lookat:=xlWhole
                End If
                End If
            Next
            .Calculation = xlCalculationAutomatic
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Optimize Code
    By floppygoat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2020, 04:52 AM
  2. optimize code if possible
    By mohadin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2019, 06:18 AM
  3. How can I optimize my code
    By viettest in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-08-2019, 05:02 PM
  4. Optimize a code
    By pezalmendra in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2015, 05:31 PM
  5. Optimize code
    By DarkKnightLupo in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 02-19-2014, 08:58 AM
  6. Optimize code
    By miso.dca in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-08-2011, 03:35 PM
  7. Optimize VBA code
    By doodlebug in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2007, 07:53 AM

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