Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Combining variable names

Thanks Tim.
Now, what if I want to combine text and a variable within
that collection.

something like:
newvar = 2
If x.Item(x.Item(var1) & x.Item("var" & newvar)) = 1

Am I able to something like that?

-----Original Message-----
Bernie,

I don't think you can do it with normal variables, but

you could do it with
objects - e.g. using a Collection you could have

something like:

Dim var1 As String
Dim var2 As String
Dim var3 As String
Dim x As New Collection

var1 = "var1"
var2 = "var2"
var3 = "var3"

x.Add key:=var1, Item:="va"
x.Add key:=var2, Item:="r3"
x.Add key:=var3, Item:=1

If x.Item(x.Item(var1) & x.Item(var2)) = 1 Then
MsgBox "Answer is 1"
End If

Only problem with using a 'keys & values' is that you

can only add each key
once - if you want to replace it wirh a different values

then you would have
to delete the item first.

HTH

Tim


"Bernie Gaile"

wrote in message
...
Hey guys,
I have 3 variables: var1, var2, var3
var1 = "va"
var2 = "r3"
I want to check 'if var3 = 1' by using var1 and var2

something like 'If var1 & var2 = 1 then'
but I've tried the above and it doesn't work

Is there a way to combine variables names like this?

Thank you,
Bernie



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining first and last names into one column Virginia Excel Worksheet Functions 1 March 11th 08 07:14 PM
Combining workbooks with some variable field names Bob Dobalina Excel Discussion (Misc queries) 8 May 17th 05 09:48 PM
Combining first and last names Lewis Shanks Setting up and Configuration of Excel 1 December 15th 04 12:27 AM
Combining Defined Names to New Name For Validation TheSpankster22 Excel Worksheet Functions 1 November 8th 04 09:20 AM
Combining names Thomas[_9_] Excel Programming 1 December 26th 03 10:40 PM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"