-
Apr 5th, 2021, 01:01 AM
#1
Thread Starter
New Member
[RESOLVED] Why don't we use double quotes when working with variables?
Hi, while writing a cell address in a range object I need to use double quotes
example: range("B5").select
But when I use variables for defining an address I don't require double quotes
example: range(x & y).select
Here x is a string and y is an integer
Can someone please explain why range("x & y") not valid since we are required to use double quotes as a convention?
-
Apr 5th, 2021, 01:35 AM
#2
Re: Why don't we use double quotes when working with variables?
This is pretty basic stuff that you really shouldn't need explaining because it's covered by beginner tutorials. Double quotes denote a literal String value. The only thing you wrap in double quotes is literal text. An expression that concatenates two variables is not literal text so it doesn't go in double quotes. This:
would be the equivalent of doing this:
and then using this:
The argument needs to be a String containing the name of a valid range. That String can be a literal or a variable or some other expression that evaluates to a String, e.g. the concatenation of two other variables.
-
Apr 5th, 2021, 02:35 AM
#3
Thread Starter
New Member
Re: Why don't we use double quotes when working with variables?
Thank you for the detailed explanation. I am new to programming and learning it from Coursera. I will make sure to check other basic tutorials next time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|