Consulting

Results 1 to 3 of 3

Thread: VBA for a calculation where the range is dynamic

  1. #1
    VBAX Newbie
    Joined
    Dec 2015
    Posts
    3
    Location

    VBA for a calculation where the range is dynamic

    Hi,
    I have a large data set of student exam results where I am trying to return the result of the calculation =SUM(range)/100, where the range is a dynamic number of exam results (one per row), for each student. As shown in the below example, the range is the Weighted Exam Scores for each student and the result of =SUM(range)/100 should be returned in column 'Weighted Avg.Score' in the first row of each student. Can anyone suggest some VBA code to do this please?


    Student Number Exam Credit
    Exam Score
    Weighted Exam Score Weighted Avg. Score
    01 20 11 210 8.1
    01 20 10 200
    01 40 8 320
    01 20 4 80
    02 10 14 140 12.1
    02 10 15 150
    02 60 13 780
    02 20 7 140
    03 20 7 140 10.2
    03 40 13 520
    03 40 13 520
    04 10 12 120 11.9
    04 10 13 130
    04 50 13 650
    04 20 10 200
    04 10 9 90
    05 40 12 480 10.8
    05 40 10 400
    05 20 10 200

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You don't need VBA, a simple formula will suffice

    =IF(A2<>A1,SUMIF(A:A,A2,D:D)/100,"")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Dec 2015
    Posts
    3
    Location
    This worked beautifully, many 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
  •