Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It looks like you are trying to do the following:
Sub test() Dim myvariable As String myvariable = "example string" MsgBox Evaluate("myvariable") End Sub It don't think it's not possible to get the value of a variable using a string containing it's name. What you could do is as follows: Sub test2() Dim j As Integer Dim varCol3 As Integer, varCol4 As Integer, varCol5 As Integer varCol3 = 13 varCol4 = 14 varCol5 = 15 For j = 3 To 5 With ActiveCell.Offset(0, j) Select Case j Case 3: .Value = varCol3 Case 4: .Value = varCol4 Case 5: .Value = varCol5 End Select End With Next j End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "kaon " wrote in message ... Hi all, I have the following code: Sub test2() Dim j As Integer Dim varCol3 As Integer, varCol4 As Integer, varCol5 As Integer varCol3 = 13 varCol4 = 14 varCol5 = 15 For j = 3 To 5 ActiveCell.Offset(0, j).Value = Evaluate("varCol" & Str(j)) Next j End Sub Why would evaluate() not evalute what I expect, i.e put the corresponding values into the cells? Thanks in advance. --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Simple question | New Users to Excel | |||
IF formula-simple question; simple operator | Excel Discussion (Misc queries) | |||
Simple Simple Excel usage question | Excel Discussion (Misc queries) | |||
simple question, hopefully a simple answer! | Excel Programming | |||
A simple question | Excel Programming |