Timeline for Find and copy pasting optimisation
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:41 | history | edited | CommunityBot | replaced http://stackoverflow.com/ with https://stackoverflow.com/ | |
| Sep 13, 2016 at 11:17 | comment | added | Mathieu Guindon | It creates a new instance of an object. | |
| Sep 13, 2016 at 9:36 | comment | added | Lollo | Moreover, couldn't I replace this: Public Sub MergeSheets() With New MergeUserForm .AddValidationRule New DistinctSheetValidationRule .Show vbModal If Not .IsCancelled Then DoWork .Selection1, .Selection2 End With End Sub with this: Public Sub MergeSheets() Dim rule As DistinctSheetValidationRule With New MergeUserForm .AddValidationRule rule .Show vbModal If Not .IsCancelled Then DoWork .Selection1, .Selection2 End With End Sub What is the New keyword for ? | |
| Sep 13, 2016 at 9:31 | comment | added | Lollo | You were absolutely right @Mat's Mug. But now when in my main sub I call MergeUserForm.AddValidationRule New DistinctSheetValidationRule the added rule to the 'Private rules As Collection` is "Nothing" and the result of the Refedit_Afterupdates are useless...I am sorry for all these comments, I am struggling to understand how to link and use this classes and all your tips are helpful ! :) | |
| Sep 12, 2016 at 16:28 | comment | added | Mathieu Guindon | @Lollo you need to have a class module named IRangeValidationRule that defines the Validate method for other classes to implement it. I don't see an IRangeValidationRule class module in your screenshot. | |
| Sep 12, 2016 at 16:19 | comment | added | Lollo | It is a class module (check the pictures I edited in my question) and yes, I am using vbModal :/ | |
| Sep 12, 2016 at 15:47 | comment | added | Mathieu Guindon | If it's not in IntelliSense after you type As, then you don't have a class module for it. An interface must be a class module. I'm not sure what the problem is with the refedit, it worked perfectly fine when I did it. Are you using vbModal when you .Show the form? It shouldn't matter at all which control has focus when the form gets hidden - it's perfectly normal and even expected that the last control that was clicked has the focus. | |
| Sep 12, 2016 at 15:42 | comment | added | Lollo | @Mat's Mug I double checked and it doesn't seem to be a typo...Intellisense doesn't offer it after the As neither. Moreover, I have a problem linked to the X-out: the refedit stays in focus even after the form is hidden. So, the macro doesn't close properly. I checked on the web and apparently it is a very common error linked to the refedit object and there's not much I can do...any idea ? | |
| Sep 7, 2016 at 14:37 | comment | added | Mathieu Guindon | Then it's probably just a typo - the class name should be offered by IntelliSense after entering the whitespace following As | |
| Sep 7, 2016 at 13:59 | comment | added | Lollo | I already did it before commenting ! :( | |
| Sep 7, 2016 at 13:51 | history | edited | Mathieu Guindon | CC BY-SA 3.0 | deleted 28 characters in body |
| Sep 7, 2016 at 13:15 | comment | added | Mathieu Guindon | @Lollo there needs to be a class module named IRangeValidationRule for that code to be compilable - I've edited my answer to clarify =) | |
| Sep 7, 2016 at 12:24 | comment | added | Lollo | Dear Mat's Mug, thank you for your detailed answer, you made me learning a huge amount of new vba features, and programming in general :) Unfortunatly, however, the code doesn't run because of this error : "user-defined type not defined", that is apparently related to this Public Sub AddValidationRule(ByVal rule As IRangeValidationRule) rules.Add rule End Sub....any idea? | |
| Sep 1, 2016 at 19:21 | comment | added | Raystafarian | Good answer! For OP - Always turn on Option Explicit. You can have it automatically by going to Tools -> Options in the VBE and checking the Require Variable Declaration option. | |
| Sep 1, 2016 at 16:45 | history | edited | Mathieu Guindon | CC BY-SA 3.0 | fixed typo |
| Sep 1, 2016 at 15:37 | history | answered | Mathieu Guindon | CC BY-SA 3.0 |