Consulting

Results 1 to 3 of 3

Thread: VBA SUM Formula help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location

    Thumbs up VBA SUM Formula help

    Hi Team,

    How to make code dynamic to cover last row if data increase?. Thanks in advance !!

    Below is my code it is giving Result 12, Instead of 33,


    Sub Test_sum()

    Dim lr As Long

    lr = Range("B100").End(xlUp)

    Range("D2") = Application.WorksheetFunction.Sum(Range("b2:B" & lr))

    End Sub

    A B
    Name Count
    a 5
    b 7
    c 10
    d 8
    e 3


    Thanks
    Mallesh

  2. #2
    VBAX Regular pike's Avatar
    Joined
    Dec 2007
    Location
    Alstonville, Australia
    Posts
    97
    Location
    Hello,
    You need to add the row property
    lr = Range("B100").End(xlUp).row

  3. #3
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location
    Thanks !

Posting Permissions

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