Home Using cell contents to set a range variable
Reply: 1

Using cell contents to set a range variable

LJIII
1#
LJIII Published in 2018-01-11 18:45:25Z

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
Tim Williams
2#
Tim Williams Reply to 2018-01-11 18:54:44Z

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

Try

Set WorkRange = Sheets("HungarianAlgorithm").Range(Range("SearchBy").Value)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.323765 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO