+ Reply to Thread
Results 1 to 10 of 10

userform takes 10sec to transfer data

  1. #1
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    userform takes 10sec to transfer data

    hi
    userform 12 sends dat to sheet1 and sheet repairs ,data is collected from sheet1 and it updates from userform all this works apart from when you click save it hangs for about 10 seconds then saves it not sure what ive done
    colin
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: userform takes 10sec to transfer data

    in your save routine you have unnecessary loops - you have found the number of rows (ctr) this is looped through although your row position is established by your combobox listindex, so in effect you are sending the same information to the same row multiple times, as there other operations also taking place (converting to Ucase) each of these are slowing the operation down and will get worse as your data builds up.
    Much the same thing will happen with your loading of comboboxes (40+ looped instances of the .Additem method) this method is really only intended for adding singular items.
    Rather than me expanding on why not to use .Additem or Rowsource I have attached a link to what I believe to be the best reference piece on the Web.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform takes 10sec to transfer data

    hi
    many thanks will run through it again and check the loops
    colin

  4. #4
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform takes 10sec to transfer data

    hi
    i have done some changes it seems to work can you give it a quick look at for me ,have taken some loops out ,only prob i have now is if you enter data and go to sheet repairs sometimes it does not add to next row ,it misses a few now and again
    regards colin
    Attached Files Attached Files
    Last edited by cfinch100; 02-04-2023 at 04:25 AM. Reason: update

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: userform takes 10sec to transfer data

    can you point me to the Userform in question.

  6. #6
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform takes 10sec to transfer data

    hi
    userform12 collects data from sheet1 and updates sheet1 also sends to sheet ()repairs but seems to be a bit hit and miss were it puts it in sheet (repairs) ,first it will put in next available row then sometimes 5 rows down ,as said ive took some loops out to stop it hanging when saving this seems to work but not sure if its right and this row not selecting next available in sheets(repairs)
    colin

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: userform takes 10sec to transfer data

    see attached - initial error (not going to envisaged row) you were referencing the wrong worksheet when finding the last row.
    For the updating of Sheet1 the listindex (corrected for zero base and header) is all that is needed (with variable 'li') note if you declare your variables at the head of the UserForm module immediately after Option Explicit the variable then carries over all Subs and can be referenced from them, if you declare a variable within a Sub it is only valid within that Sub.
    any queries post back in this thread it is easier to pick up then.
    p.s. you will note the file size is little smaller and faster with the colour formatting of just one sheet removed - if you decide to investigate 'structured tables' you will also notice better speed providing you reference them properly.
    Attached Files Attached Files
    Last edited by torachan; 02-04-2023 at 01:03 PM.

  8. #8
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform takes 10sec to transfer data

    hi
    thankyou will take onboard about declaring variables at the beginning ,you have totally lost me with the coding as have not tried cells ect but will have a look now ,thanks for help
    colin

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: userform takes 10sec to transfer data

    I will have to look the details up, some years ago this subject was debated hotly and one of the experts of the day set up a parallel test which demonstrated on a large dataset with fragmented targeting cell referencing was 2.5 faster than individual range referenced cells - however if I was to enter a large contiguous block of data I would put it in an array and target it to a range in one hit - if you are more comfortable using ranges do so but ensure your referencing is correct.
    One other item that would help speed, there is no need to activate sheets providing your reference is correct nor any need to reference the ActiveWorkBook, you are already in it.
    The more compact your app the faster it will be, use 'With' where ever possible - rather than switching between a multitude of forms use the MultiPage on a single UserForm, even if you hide the tabs and use a command button and menu to navigate.

  10. #10
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform takes 10sec to transfer data

    Thankyou for info my wifi down at minute so i thiught i would send by phone
    Colin

+ 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. Transfer userform data
    By neilsy1 in forum Excel General
    Replies: 1
    Last Post: 08-27-2016, 04:26 AM
  2. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  3. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  4. [SOLVED] Userform to transfer data to another userform
    By Oeysbrei in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2012, 04:46 PM
  5. Transfer Data in Userform
    By vin1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2012, 09:57 AM
  6. Run macro every 10sec.
    By chinrose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2011, 02:16 AM
  7. Userform takes variable data
    By vin1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2011, 08:02 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