+ Reply to Thread
Results 1 to 8 of 8

VBA code is slowing down the worksheet function

  1. #1
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    VBA code is slowing down the worksheet function

    Dear Forum,

    Kindly help me on the following issue.

    I want to do an auto-generation of serial number for my data set. Hence i have used the following VBA code.

    Please Login or Register  to view this content.
    But this code makes the worksheet function very slow. More over i have other two codes in the same sheet, (Sub and End sub) and (Function and End Function). is it only making trouble? kindly help me on this.

    Regards

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code is slowing down the worksheet function

    Hi,

    This code will run whenever you select any cell on the sheet which is very inefficient. It would be better as a Worksheet_Change event and probably restricted to only running when a value in column B is changed.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Re: VBA code is slowing down the worksheet function

    Dear Mr. Xlnitwit,

    Thanks for your prompt guidance and suggestion.

    The following are the right code, orelse could you please modify the code and help me.

    Please Login or Register  to view this content.
    Please help me
    Next i
    End Sub

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code is slowing down the worksheet function

    Should the serial number remain the same for a row once it has been allocated? Your original code would change the serial numbers if, for example, you deleted a row or sorted the data- is that what you want, or do you want the numbers to remain the same and assign the next highest value to a new row?

  5. #5
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Re: VBA code is slowing down the worksheet function

    Yes sir, It should change, if i deleted a row, next serial number should be allocated for the respective rows.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code is slowing down the worksheet function

    I fear that does not answer my question really. Consider this scenario-
    1. You have this data set
    A
    B
    5
    1
    Item1
    6
    2
    Item2
    7
    3
    Item3
    8
    4
    Item4
    9
    5
    Item5

    2. You then delete row 7 (Item3)
    3. Your current code would produce this
    A
    B
    5
    1
    Item1
    6
    2
    Item2
    7
    3
    Item4
    8
    4
    Item5

    and the next new row would be allocated number 5.

    Is that what you want, or do you want this to be the result
    A
    B
    5
    1
    Item1
    6
    2
    Item2
    7
    4
    Item4
    8
    5
    Item5

    and the next new row would be allocated number 6?

  7. #7
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Re: VBA code is slowing down the worksheet function

    Exactly i need like the 2nd table only.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: VBA code is slowing down the worksheet function

    Then I believe this will do the trick
    Please Login or Register  to view this content.
    and it will only run when you change something in column B.

+ 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. vba code slowing things down.
    By Zimmerman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-05-2015, 11:19 AM
  2. [Question] =IFCountA is slowing down my Code
    By SirRubberDucky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2014, 12:35 PM
  3. Why this code is slowing down
    By TheMaciej in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2013, 01:11 AM
  4. VBA code slowing up worksheet
    By dsrt16 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2009, 05:40 PM
  5. SUMPRODUCT formulas slowing worksheet significantly
    By Jason_2112 in forum Excel General
    Replies: 4
    Last Post: 01-22-2009, 12:25 PM
  6. a few questions about slowing code and its quality
    By robbi100 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-10-2009, 02:26 PM
  7. Code I Have In A Module Slowing Down Data Entry
    By PIPPIBOOKS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-29-2008, 06:24 PM

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