Consulting

Results 1 to 20 of 25

Thread: Still Stuck On A loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Posts
    75
    Location
    If cell Cx on "Detail report" = "Pr Code" then the loop should look at the the corresponding column "I" on "As Built" associated with that "Pr Code" and add those numbers together. Would it be easier to say something like:
    For x=1 to 100001
    If sheets("Detail Report").Range("E" & x) = Sheets("As Built").Range("L" & X) then
          Worksheets("Generalized Report").Range("C16").Value = Worksheets("Generalized Report").Range("C16").Value + WorksheetFunction.Sum(Worksheets("As Built").Range("I" & x).Value)
    End If
    The value in Column E on Detail Report would match the value in Column L on As built to execute the loop. I have tried it both ways and I still run into an issue that adds multiple times or adds wrong.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Quote Originally Posted by NWE View Post
    If cell Cx on "Detail report" = "Pr Code" then the loop should look at the the corresponding column "I" on "As Built" associated with that "Pr Code" and add those numbers together.
    Where on Detail is the PR Code that is to be looked up?
    ____________________________________________
    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 Regular
    Joined
    Nov 2018
    Posts
    75
    Location
    I have uploaded an attachment of the detail report page.

    "Pr Code" exists in column C (Along with other items, that may be used to replicate the process later)
    Attached Files Attached Files

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Come on mate, what use is that workbook? I assume that sheet is supposed to be Detail Report, but what about the other two? We can't help you if you obstruct us.
    ____________________________________________
    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

Tags for this Thread

Posting Permissions

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