0

I'm trying to run code on a range that changes through different iterations of a loop. Here is what I would like the code to run if the value in range("SearchBy") = ZeroCounts

Dim WorkRange As range
Set WorkRange = range("ZeroCounts")

Here is how I am attempting to solve this but I can't find a way that works without returning errors. Any ideas?

Dim dummy As String
dummy = """" & range("SearchBy").Value & """"

Dim WorkRange As range
WorkRange = Sheets("HungarianAlgorithm").range(dummy)

WorkRange.Select
1
  • Protip: when you ask a question about something that raises errors, it's usually a good idea to mention what the errors are. Commented Jan 11, 2018 at 18:54

1 Answer 1

1

You need to use Set when assigning a value to an object-type variable

Try

Set WorkRange = Sheets("HungarianAlgorithm").Range(Range("SearchBy").Value)
Sign up to request clarification or add additional context in comments.

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.