How do I use a variable in the place of a sheet name

F

FCLinux

In the following code snippet, from a macro I am writing, how do I use
name as a variable rather than a predefined sheet name in this code
line - ActiveCell.Offset(row, col).FormulaR1C1 = "=name!RC*1.0"


Sample code snippet from my Excel macro

Do While ActiveCell.Offset(0, col) <> ""
row = 2
Do While ActiveCell.Offset(row, col - 1) <> ""
ActiveCell.Offset(row, col).FormulaR1C1 = "=name!RC*1.0"
row = row + 1
Loop
DoEvents
col = col + 1
Loop
 
R

Rick Hansen

Good Morning,

if name variable is s string type variable, this should do the trick for
you..

enjoy, Rick


Dim name as string

ActiveCell.Offset(row, col).FormulaR1C1 = "=" & name" & "!RC*1.0"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top