Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax pls (97+)

    Need the correct syntax pls
    lrows = 282
    ActiveCell.Formula = "=sum($d$2:$d$282)"--this works
    ActiveCell.Formula = "=sum($d$2:$d & lrows)"---this is wrong
    need correct syntax pls
    thanx
    smbs

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: syntax pls (97+)

    You must place the variable outside the quotes, otherwise VBA will see it as literal text.

    ActiveCell.Formula = "=SUM($D$2:$D" & lrows & ")"

  3. #3
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: syntax pls (97+)

    many thanks

  4. #4
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: syntax pls (97+)

    if the varible is a range whats the syntax
    set rng = .range("d2:d282")
    ActiveCell.Formula = "=SUM(" & rng")" ---????

    excuse my ignorance
    Thanx

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: syntax pls (97+)

    ActiveCell.Formula = "=SUM(" & rng.address & ")"

    Steve

  6. #6
    2 Star Lounger
    Join Date
    Dec 2001
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: syntax pls (97+)

    many thanks
    smbs

Posting Permissions

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