reading clipboard contents into array in VBA
Range("C" & CStr(j) & ":C" & CStr(k)).Select
Range("C" & CStr(j) & ":C" & CStr(k)).Copy
I am reading the contents of a column into the clipboard and I want to loop through every element.
The question is how do I loop through it?
The contents o开发者_如何学运维f the clipboard look like this:
1234
21345234
1234512345
123452135
123451235
2345
alternatively I should probably be looping through J and K? Can you please show me how to do this thank you
You don't need to use the clipboard for this, instead:
Dim workingArray as Variant
workingArray = Range ("C" & CStr(j) & ":C" & CStr(k))
Now you can work through workingArray, note that it's treated as a two-D array.
You can loop through the range without the need for any weird syntax like this:
Dim cel as Range
For Each cel in Range(Cells(j,3), Cells(k,3))
MsgBox cel.Value
Next cel
Note that the '3' in this case means the range is in the third column (which is 'C')
精彩评论