ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax for a formulae in Visual Basic (https://www.excelbanter.com/excel-programming/418922-syntax-formulae-visual-basic.html)

Highlystrung

Syntax for a formulae in Visual Basic
 
Im trying to put a formulae into a spreadsheet in a program as thus:

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

This works fine but Id like to replace the numbers giving the columns with
variables i and j. I cant seem to get a syntax sorted that doesnt 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,
--
thanks, Neil

Tim Williams

Syntax for a formulae in Visual Basic
 

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

should work

Tim

"Highlystrung" wrote in message
...
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,
--
thanks, Neil




Highlystrung

Syntax for a formulae in Visual Basic
 
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" wrote:


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

should work

Tim

"Highlystrung" wrote in message
...
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,
--
thanks, Neil






All times are GMT +1. The time now is 06:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com