+ Reply to Thread
Results 1 to 3 of 3

VBA SUMIF Loop - Repeat for multiple columns

  1. #1
    Registered User
    Join Date
    08-13-2013
    Location
    London, Englamd
    MS-Off Ver
    Excel 2007
    Posts
    5

    VBA SUMIF Loop - Repeat for multiple columns

    Hello All,

    I am pretty good with excel but am only just getting in to VBA codes and macros and so I was hoping that someone can help me with my problem below.

    I have a list of people in D4:D21 and next to them I have the hours that they worked (so Week 1 is column E, Week 2 Column F, etc...).
    I have figured out the code which will let me 'sumif' the hours in C25:C29 based on the person specified in B25:B29. This code is as follows:

    Sub SUMIF_LOOP()
    i = 25
    Do While Range("B" & i).Value <> ""
    Range("c" & i).Formula = Application.SumIf(Range("D:D"), Range("B" & i), Range("E:E"))

    i = i + 1

    Loop

    End Sub

    Can any please help improve this code so that after it loops through Column E and provides the answer in column C, it will repeat the sumif process through Column F and place the answer in Column D?

    Thanks i advance,
    Simon
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA SUMIF Loop - Repeat for multiple columns

    Try the attached.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-13-2013
    Location
    London, Englamd
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: VBA SUMIF Loop - Repeat for multiple columns

    Thanks AB33 - That's exactly what I needed! Thanks also for making the code so simple so that I can work through it and understand it.

    Simon

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. sum bold cells in a column...repeat across multiple columns
    By techguy24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 11:02 AM
  2. Need macro help with transposing columns to rows and repeat a row value multiple times
    By InnovativeAJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2012, 11:53 AM
  3. Excel 2007 : Repeat Columns in multiple sheets
    By jbode in forum Excel General
    Replies: 1
    Last Post: 01-04-2011, 04:39 PM
  4. Repeat function on multiple columns
    By kyhii in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-25-2010, 06:16 AM
  5. Calculating percentages for multiple repeat value columns.
    By momus12 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-07-2008, 12:42 PM

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