Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Variable in cell reference

Hello

I'm using the following code to sum a cell range I want to use
variablles but it's not working


strEndCell = ActiveCell.SpecialCells(xlLastCell).Address

strEndCell = Mid(strEndCell, 4)
j = Val(strEndCell)
j = j + 2
str1 = "H" & j
j = j - 2
Range(str1).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-j]C:R[-1]C)"


What I'm trying to do is find the last cell in a sheet then go 2 cells
below that and SUM a column

I the SUM formula I'm using "j" as a varable to point to a cell

I'm not sure if I'm going about it in the right manner

Any suggestions please

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Variable in cell reference

Dim cell As Range

Set cell = ActiveCell.SpecialCells(xlLastCell)

cell.offset(2, 0).FormulaR1C1 = "=SUM(R1C:R[-1]C)"


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Super Slueth" wrote in message
...
Hello

I'm using the following code to sum a cell range I want to use
variablles but it's not working


strEndCell = ActiveCell.SpecialCells(xlLastCell).Address

strEndCell = Mid(strEndCell, 4)
j = Val(strEndCell)
j = j + 2
str1 = "H" & j
j = j - 2
Range(str1).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-j]C:R[-1]C)"


What I'm trying to do is find the last cell in a sheet then go 2 cells
below that and SUM a column

I the SUM formula I'm using "j" as a varable to point to a cell

I'm not sure if I'm going about it in the right manner

Any suggestions please

Many thanks



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
Variable Cell Reference Andrew Excel Discussion (Misc queries) 3 December 29th 06 03:35 PM
Variable Cell Reference 0-0 Wai Wai ^-^ Excel Worksheet Functions 2 June 27th 06 07:05 PM
How do I use a variable in a cell reference? jsp377 Excel Discussion (Misc queries) 3 January 27th 05 01:43 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 06:08 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"