LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Using variable in Excel formula in VBA statement

Excel 2000 VBA using R1C1 notation in the Workbook

I've written a simple "Journal" (check register) in a worksheet, and
I'm trying to program split checks. On the line below the individual
items in the split, in a different column, I want to total all of the
individual values in the split (state a total value for the check). I
want to generate the formula to do that with a VBA statement.

The following code runs OK and does *almost* what I want to do:

ActiveCell.Offset(i1, 3).FormulaR1C1 = "=""Total of check is $
""&FIXED(SUM(R[-4]C[3]:R[-1]C[3]),2)"

What I really need is for the "4" in "R[-4]" to not be a hard coded
number, but to be obtained from the value of an integer variable.

The name of the variable I'm using is "i1", and although it's a cell
reference in "normal" notation, it seems to work fine in all of the
other code in my macro. It is declared in a Dim statement:
Dim i1 as Integer
It works fine in the "Offset(i1, 3)" part of the above formula.

Simply substituting "-i1" for "-4" does not work. I've guessed at
some variations which also do not work.

When the code fails, I get no runtime error in the macro, but the
designated cell is (apparently) empty; no formula at all is placed in
the desingated cell.

Thanks for any help

Fred Holmes

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable statement doobie Excel Discussion (Misc queries) 3 November 11th 09 07:42 AM
IF Statement Variable Jase4now Excel Discussion (Misc queries) 3 September 25th 07 10:48 PM
Variable IF statement (in VBA) Post Tenebras Lux Excel Programming 3 July 7th 06 03:28 PM
how can i calculate a three variable if statement in excel Jennifer Samuel Excel Worksheet Functions 2 February 13th 06 04:21 AM
Macro Creating Variable and using variable in a SQL statement Jimmy Excel Programming 4 October 25th 04 02:36 AM


All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"