Generate a formula from VBA

py1ro

Board Regular
Joined
Sep 30, 2005
Messages
70
I'm having difficulties finding a way to create the following type of formula:

=sumif("A" & begin, "A" & end; "A" & end +2; "B" & begin, "B" & end)

I tried FORMULA= instead of FORMULAR1C1= but cannot get beyond the quotation marks.

Is it possible at all? I found no examples.

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
hallo, py1ro,
(you must love greek !?)

try something like this
Code:
Sub Test()
FR = 1
LR = 5

    Range("A10").FormulaR1C1 = "=SUMIF(R" & FR & "C1:R" & LR & "C1,R" & LR + 2 & "C1,R" & FR & "C2:R" & LR & "C2)"

End Sub
how I found this ?
just asked my best friend: the macro recorder
then carefully replaced some parts

two examples
Range("A1")
Range("A" & FR)

"=R1C1"
"=R" & FR & "C1"

kind regards,
Erik
 
Upvote 0
Hi Eric, thanks for the FAST reply! I will play with this tmw. It´s midnite here in Rio de Janeiro and I was just going to bed. Greek? If you refer to my "name", it is my hamradio callsign!!!

Best regards
Rolf, my real name!
 
Upvote 0
Hi Eric

It actually worked! Thanks indeed for bringing me much closer to understanding R1C1 !

Hartelijke groeten van Rio! (sp may be wrong)
(I lived 3 years in Indonesia in a past life...)
Rolf
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top