Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Calculating Column and off setting calculated value to another column

The code below is not calculating the correct column, which should be
"J", not L, where the results are place...not sure what I've done.

With wks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("J1", .Cells(.Rows.Count, "J").End(xlUp)) _
.Cells.SpecialCells(xlCellTypeConstants)
On Error GoTo 0


If myRng Is Nothing Then
MsgBox "no constants"
Exit Sub
End If


For Each myArea In myRng.Areas
myFormula = "=sum(r[-1]c:r[-" & myArea.Cells.Count & "]c)"
Set FormCell = myArea.Cells(myArea.Cells.Count).Offset(1,
0)
With FormCell
.FormulaR1C1 = myFormula
.Offset(0, 2).Value = .Value
.Offset(0, 2).Font.Bold = True
.FormulaR1C1 = ""
End With
Next myArea
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Calculating Column and off setting calculated value to anothercolumn

On Feb 1, 10:09 am, S Himmelrich wrote:
The code below is not calculating the correct column, which should be
"J", not L, where the results are place...not sure what I've done.

With wks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("J1", .Cells(.Rows.Count, "J").End(xlUp)) _
.Cells.SpecialCells(xlCellTypeConstants)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "no constants"
Exit Sub
End If

For Each myArea In myRng.Areas
myFormula = "=sum(r[-1]c:r[-" & myArea.Cells.Count & "]c)"
Set FormCell = myArea.Cells(myArea.Cells.Count).Offset(1,
0)
With FormCell
.FormulaR1C1 = myFormula
.Offset(0, 2).Value = .Value
.Offset(0, 2).Font.Bold = True
.FormulaR1C1 = ""
End With
Next myArea
End With


Hello S Himmelrich,

Your new range myRng is only 1 column wide. It holds the contents of
column "J". Your code below Offsets from this address to 2 columns
over. This places you back on the worksheet in column "L".

With FormCell
.FormulaR1C1 = myFormula
.Offset(0, 2).Value = .Value <-----------
.Offset(0, 2).Font.Bold = True <-----------
.FormulaR1C1 = ""
End With
Next myArea
End With

Sincerely,
Leith Ross
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
Calculating column A * column B = Results in another column jhun Excel Worksheet Functions 2 March 30th 10 05:13 AM
Calculated Column Using Loop [email protected] Excel Programming 3 February 6th 07 02:19 PM
Setting column width if #### appears in column qwerty[_2_] Excel Programming 14 April 9th 06 04:05 PM
using a calculated column value within a range gvm Excel Programming 1 September 17th 05 02:02 PM
Calculating totals in a column based on a lookup in another column Michael Wright via OfficeKB.com Excel Worksheet Functions 1 April 15th 05 09:52 AM


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