ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Proper Syntax Sought For NewBie Excel Programmer (https://www.excelbanter.com/excel-programming/313533-proper-syntax-sought-newbie-excel-programmer.html)

Sprinks

Proper Syntax Sought For NewBie Excel Programmer
 
How can I:

- refer to the value of a cell in column B, in the same row as the active
cell?
- Assign a cell reference to a variable, so that I can later assign it a
value, as in MyCellRef = someaddress; MyCellRef.Formula = @sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks

Chip Pearson

Proper Syntax Sought For NewBie Excel Programmer
 
Sprinks,

Try

Dim Rng As Range
Set Rng = ActiveCell.EntireRow.Cells(1,"B")
Rng.Formula = "=SUM(A1:A10)"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Sprinks" wrote in message
...
How can I:

- refer to the value of a cell in column B, in the same row as
the active
cell?
- Assign a cell reference to a variable, so that I can later
assign it a
value, as in MyCellRef = someaddress; MyCellRef.Formula =
@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks




keepITcool

Proper Syntax Sought For NewBie Excel Programmer
 
if you want to learn to program VBA,
please do yourself a favour:
buy (and read) a decent book like WalkenBach's
Excel 2003 Power Programming


From your little snippet I presume your an (ex) lotus user.
in excel formulas always start with = not @

'define a variable
dim rng as range

'Assign it to a "known" address
set rng = ActiveSheet.Range("A1")

'Assign it to the cell in column B on the "current" cell's row.

Set rng = Activecell.EntireRow.Cells(1,2)


For formulas with relative referencing it's easiest to use the
FormulaR1C1 property...
sum column2 to column4 on the current row..

rng.FormulaR1C1 = "=SUM(RC2:RC4)"


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?U3ByaW5rcw==?=" wrote:

How can I:

- refer to the value of a cell in column B, in the same row as the
active cell?
- Assign a cell reference to a variable, so that I can later assign it
a value, as in MyCellRef = someaddress; MyCellRef.Formula =
@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks



Jean-Yves[_2_]

Proper Syntax Sought For NewBie Excel Programmer
 
Hi,

1. refer to the value of a cell in column B, in the same row as the active
cell
cells(activecell.Row,2)

2.Assign a cell reference to a variable
Dim MyCellRef as String
MyCellRef =Activecell.address
Range(MyCellRef ).formula = )"
Or
Dim MyCell as Range
Set MyCell =Activecell 'or range("A1") for example

MyCell.formula = )"

'when finished
set MyCell = Nothing

Regards,

Jean-Yves



"Sprinks" wrote in message
...
How can I:

- refer to the value of a cell in column B, in the same row as the active
cell?
- Assign a cell reference to a variable, so that I can later assign it a
value, as in MyCellRef = someaddress; MyCellRef.Formula =

@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks




Sprinks

Proper Syntax Sought For NewBie Excel Programmer
 
Thanks, Chip. Just what I was looking for.

Sprinks

"Chip Pearson" wrote:

Sprinks,

Try

Dim Rng As Range
Set Rng = ActiveCell.EntireRow.Cells(1,"B")
Rng.Formula = "=SUM(A1:A10)"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Sprinks" wrote in message
...
How can I:

- refer to the value of a cell in column B, in the same row as
the active
cell?
- Assign a cell reference to a variable, so that I can later
assign it a
value, as in MyCellRef = someaddress; MyCellRef.Formula =
@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks





Sprinks

Proper Syntax Sought For NewBie Excel Programmer
 
keepItcool,

Thank you for your solutions and book recommendation.

'@' -- guess you identified my age, too. Anyone in business my age is
an ex-Lotus-user!

Sprinks

"keepITcool" wrote:

if you want to learn to program VBA,
please do yourself a favour:
buy (and read) a decent book like WalkenBach's
Excel 2003 Power Programming


From your little snippet I presume your an (ex) lotus user.
in excel formulas always start with = not @

'define a variable
dim rng as range

'Assign it to a "known" address
set rng = ActiveSheet.Range("A1")

'Assign it to the cell in column B on the "current" cell's row.

Set rng = Activecell.EntireRow.Cells(1,2)


For formulas with relative referencing it's easiest to use the
FormulaR1C1 property...
sum column2 to column4 on the current row..

rng.FormulaR1C1 = "=SUM(RC2:RC4)"


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?U3ByaW5rcw==?=" wrote:

How can I:

- refer to the value of a cell in column B, in the same row as the
active cell?
- Assign a cell reference to a variable, so that I can later assign it
a value, as in MyCellRef = someaddress; MyCellRef.Formula =
@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks




Sprinks

Proper Syntax Sought For NewBie Excel Programmer
 
Thanks, Jean-Yves. More "arrows in the quiver".

Best regards.

Sprinks

"Jean-Yves" wrote:

Hi,

1. refer to the value of a cell in column B, in the same row as the active
cell
cells(activecell.Row,2)

2.Assign a cell reference to a variable
Dim MyCellRef as String
MyCellRef =Activecell.address
Range(MyCellRef ).formula = )"
Or
Dim MyCell as Range
Set MyCell =Activecell 'or range("A1") for example

MyCell.formula = )"

'when finished
set MyCell = Nothing

Regards,

Jean-Yves



"Sprinks" wrote in message
...
How can I:

- refer to the value of a cell in column B, in the same row as the active
cell?
- Assign a cell reference to a variable, so that I can later assign it a
value, as in MyCellRef = someaddress; MyCellRef.Formula =

@sum(BegVal..EndVal)

Thanks for any and all assistance.
Sprinks






All times are GMT +1. The time now is 01:50 PM.

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