Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,646
Default entering formula using cells notation

If you don't tell us the rules of determining cell references, I can give you
only general hints:

R1C1 style creates absolute references: R1 means row1, C1 means column1 that
is column A, so R1C1 means cell A1.
R[1]C[1] style creates relative references: R[1] means row 1 row down from
the hosting cell, C[1] means column 1 to the right from the hosting cell,
that is - if the hosting cell is A1 - R[1]C[1] means cell B2.

If you want to use variables, like k and l in your example, instead of
constant values between [] brackets, you have to use the following syntax:

ActiveCell.FormulaR1C1 ="R[" & k & "]C[" & l & "]"

means cell k row down, l column to the right from the active (hosting) cell.


Regards,
Stefi

€žjk22€ ezt Ã*rta:

Hi Stefi -

I would like to use the For loop in the macro to determine the formula. The
formula will have some parts relative to the cell it is being put in, and
other parts absolute. I can't figure out the relative parts using the
counters (k & l) which allow it to appear as a formula in excel spreadsheet.

As for how it appears in the spreadsheet - i expect it will appear as A1/B1
style. I'm not worried if it uses $A$1 style for the spreadsheet (although
that might be good to know as well) because the macro is intended to run
through the spreadsheet and set up all the formulas at the beginning.

Thanks

Thanks




"jk22" wrote:

Thanks guys - yes my example did have a circular reference - good point.

I have tried the suggestions but cannot make it work.

However I would like to formula to show up in excel spreadsheet as it does
using absolute referencing e.g. Cells(k + l, 20).Formula = "=A1/B2"

But using the relative referencing with cells notation to determine the
formula.

Any other suggestions appreciated.




"jk22" wrote:

Hi - I am trying to write the following in a macro in excel

For k = 8 to 1000
.......
For l = 1 To 50
If Cells(k + l, 2) < "" Then
Cells(k + l, 19).Formula = "=cells(k+l,19)/cells(k,19)" - does not
work in xls
Cells(k + l, 20).Formula = "=A1/B2" -
works in xls
End If
Next
.........

Can anyone suggest how to do this in loops?

Reply
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
Entering dates into cells as mm/yy or yy dabarr Excel Discussion (Misc queries) 4 September 1st 07 06:18 PM
Entering Times in Cells denise Excel Discussion (Misc queries) 2 February 1st 07 02:44 PM
Scientific notation in text cells miles Excel Discussion (Misc queries) 3 December 7th 06 10:59 PM
Entering text in cells Hallway Excel Discussion (Misc queries) 4 September 26th 06 04:49 AM
Entering zeros in cells jay_perry01 Excel Discussion (Misc queries) 1 January 16th 06 07:25 PM


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

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

About Us

"It's about Microsoft Excel"