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
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
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'.
hi
many thanks will run through it again and check the loops
colin
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
Last edited by cfinch100; 02-04-2023 at 04:25 AM. Reason: update
can you point me to the Userform in question.
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
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.
Last edited by torachan; 02-04-2023 at 01:03 PM.
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
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.
Thankyou for info my wifi down at minute so i thiught i would send by phone
Colin
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks