0
  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 of 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

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.