vba - User defined types in arrays/collections and for each loops -
In a popup, VBA shows that I do not have permission to iterate through an array with user defined types. I wrote a little code and wondered how I can work about it. Here is a small example that I want to be able to focus on.
Option Clear Type Information Source string Destination as string Expiry type Sub-specialCopy () Dim Target Version as AllTargets Information (as information): AllTargets = SetAllTargets () AllTargets CopyValues each target (target) in the next End Sub function for SetAllTargets () as information () dimmed as an information: A = SetInfo ("A1", "B1") Dim B information form In: B = SetInfo ("A2", "B2") Dim AllTargets () Info Set AllTargets = Sir VI (A, B) as the termination function SetInfo (source string, the target string) information as the SetInfo.source = source SetInfo. Destination = destination end function sub-copy (target as information target) range (target.source). Select the selection. Border range (target.destination) Select the selection. Paste Special Paste: = xlPasteValues, Operation: = xlNone, SkipBlanks _: = False, Transpose: = False End Sub How do I access my AllTargets array Repeat? Since I am unable to compile it, there can be more than one problem here. I'm not completely sure that the way I set a valid syntax to the AllTargets list.
I restarted the example to reduce the problems in the code: Code Array went away - at least still There is no problem in it which I can not solve now
I think the root cause was the same: using user-defined types, I have been marked as a comment where I think the problems are located.
You can not add UDT to the collection or why I do not know the dictionary, but it is contained in the language . You can create a simple custom square that works just like the UDT. I do not use UDTs at any time and prepare only one class to avoid these strange limitations.
Create a new class module (insertion - module). Go to Property Sheet (F4) and change the name property to CNFO.
In a class, CNF
string as private mSource, get the string public property source as mDestination () as string source = mSource termination property public Property Let Source (as RHS String) mSource = RHS End Property Public Property Destination () String Destination = mDestination End Property Public Property Let Destination (RHS) MDestination = RHS ending property in a standard module
sub-specialCopy () dim target variant retrospected as AllTargets form of archive In: Set AllTargets = SetAllTargets () AllTargets CopyValues' 2 for each goal in the target Unknown if it could be possible next to the end sub function setAllTargets () as a Coinfo archive: A = SetInfo set ("A1", "B1") as Dim B CInfo: Set B = SetInfo SetAllTargets = SetAllTargets (set "A2", "B2") SetAllTargets.Add a SetAllTargets.Add B & C Function SetInfo (as the source string, as the destination string) SetInfo = New CInfo SetInfo.Source = Source SetInfo.Destination = Destination End Function sub CopyValues (ByRef target) as the target category (target. Source). Select the selection. Copy limit (target.Destination). Select the selection. Paste Special Paste: = xlPasteValues, Operation: = xlNone, SkipBlanks _: = False, Transpose: = False End Sub
Comments
Post a Comment