Syntax for a formulae in Visual Basic

H

Highlystrung

I’m trying to put a formulae into a spreadsheet in a program as thus:

ActiveCell.FormulaR1C1 = "=RC[6] & ""_"" & RC[7]"

This works fine but I’d like to replace the numbers giving the columns with
variables i and j. I can’t seem to get a syntax sorted that doesn’t fall
over. Can anyone help?

Here's one variant that I tried: ActiveCell.FormulaR1C1 = "=RC[" & i & "]" &
"_" & "RC[" & j & "]" where i and j are variables. Clearly not doing
something right! Any help greatly appreciated,
 
T

Tim Williams

ActiveCell.FormulaR1C1 = "=RC[" & i & "] & ""_"" & RC[" & j & "]"

should work

Tim
 
H

Highlystrung

Yes, it does. I'm sure I've tried this variant as I've tried many in my
frustration but many thanks anyway!
--
thanks, Neil


Tim Williams said:
ActiveCell.FormulaR1C1 = "=RC[" & i & "] & ""_"" & RC[" & j & "]"

should work

Tim

Highlystrung said:
I'm trying to put a formulae into a spreadsheet in a program as thus:

"=RC[6] & ""_"" & RC[7]"

This works fine but I'd like to replace the numbers giving the columns
with
variables i and j. I can't seem to get a syntax sorted that doesn't fall
over. Can anyone help?

Here's one variant that I tried: ActiveCell.FormulaR1C1 = "=RC[" & i & "]"
&
"_" & "RC[" & j & "]" where i and j are variables. Clearly not doing
something right! Any help greatly appreciated,
 

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