+ Reply to Thread
Results 1 to 4 of 4

ActiveCell.Formula incorrect value

Hybrid View

khalid79m ActiveCell.Formula incorrect... 11-14-2007, 01:23 PM
Leith Ross Hello khalid79m, You left... 11-14-2007, 01:35 PM
royUK Does this help? Option... 11-14-2007, 01:40 PM
khalid79m Thanks 02-21-2008, 10:59 AM
  1. #1
    Forum Contributor
    Join Date
    12-16-2006
    Posts
    349

    ActiveCell.Formula incorrect value

        Sheets("Total").Select
    
        Dim Lastrow As Long
        Application.ScreenUpdating = False
        Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
    
        Range("M4").Select
        ActiveCell.FormulaR1C1 = ("C1:C" & Lastrow)
    i need the fomula to sum up c1:c & lastrow but this doesnt work, it just puts "C1:C4" into the cell
    Last edited by khalid79m; 11-14-2007 at 01:27 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello khalid79m,

    You left out the SUM function, and using "C1 to last row" isn't R1C1 formula style. Stick with A1 style when writing macros. You rarely need to select cells when writing macros in VBA.
       Sheets("Total").Select
    
        Dim Lastrow As Long
        Application.ScreenUpdating = False
        Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
    
        Range("M4").Formula = "=SUM(C1:C" & Lastrow & ")"
    Sincerely,
    Leith Ross

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Does this help?

    Option Explicit
    
    Sub sumIt()
    'this will place the total of the cells in B into 4
        Dim rng    As Range
        Dim dSum   As Double
        Dim Lastrow As Long
        With Sheets("Total")
            Lastrow = .Cells(.Rows.Count, 2).End(xlUp)
            dSum = Application.WorksheetFunction.Sum(rng)
            .Cells(4, 13).Value = dSum
        End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    12-16-2006
    Posts
    349

    Thanks

    Very useful . Thanks Mate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1