Why?!
MZ Tools makes life easier for the Excel VBA coder
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Why?!

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Hengelo
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Sub Test()
    [A1].End(xlToRight)(1, 2).Formula = "=SUM([A1]:[A1].End(xlToRight))"
    End Sub

    Why doesn't this macro work?

    I have x numbers in row 1. I want to total the numbers in the cell next to Ax!
    Best regards,

    Martin J.A. Maatman Oonk

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Sub Test()
    [A1].End(xlToRight)(1, 2).Formula = "=SUM([A1]:[A1].End(xlToRight))"
    End Sub
    Formula needs a string representing the formula or value you want to place in a cell. You're trying to evaluate something (End(xltoright)) inside of a string - you need something like this:-

    [a1].End(xlToRight)(1, 2).Formula = "=sum(A1:" & Range("A1").End(xlToRight).Address & ")"

    HTH,
    D

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Hengelo
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-03-02 05:16, dk wrote:
    Sub Test()
    [A1].End(xlToRight)(1, 2).Formula = "=SUM([A1]:[A1].End(xlToRight))"
    End Sub
    Formula needs a string representing the formula or value you want to place in a cell. You're trying to evaluate something (End(xltoright)) inside of a string - you need something like this:-

    [a1].End(xlToRight)(1, 2).Formula = "=sum(A1:" & Range("A1").End(xlToRight).Address & ")"

    HTH,
    D
    Thank U!!!
    Best regards,

    Martin J.A. Maatman Oonk

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com