Jump to content

Referencing Worksheet Cells In Database Arguments


Recommended Posts

This is driving me crazy. I am trying to use a worksheet cell as an argument. I can do it one way, but not another. 

 

First off:

This works: =DATABASE((L='Design Layer 1'))

I get a list of everything on that layer.

 

And instead of a hard value, I can substitute worksheet cell B1:

This works: =DATABASE((L=B1))

...and then I can modify cell B1 to change the database.

 

I can instead make a database based on a fieldvalue if it's hard-coded:

This works: DATABASE(('TestRecord'.'TestField'='101'))

....and it will return all objects that have that record field being 101.

 

But when I go to reference a cell in that formula, I get nothing but errors:

This does not work: DATABASE(('TestRecord'.'TestField'=B1))

 

What am I missing? I have tried everything I can think of. Thanks in advance!

Link to comment

I have found that Criteria don't like to be partially text and partially cell references.

 

I have not tested, but I know that if you set the referenced cell to the entire criteria it will work.

 

so if you set B1 to:

 

((L='Design Layer-1'))

 

And then use

 

=Database (B1)

 

You should be OK.

 

I would "guess", but I have not tested that

 

=Database(Concat('((L=',CHR(39),B1,CHR(39),'))')

 

would work also.

 

The CHR(39) is the character for a single quote mark that you need to surround the string coming from cell B1. You can also use three single quotes in a row to "escape" the single quote marks, but I find that really hard to read and debug.

 

What this is doing is making a single string out of. "((L=",  single quote, string from B1, single quote, "))"

 

HTH

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...