Consulting

Results 1 to 2 of 2

Thread: insert sum or =+ formula based on value in another column for variable rows

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    57
    Location

    insert sum or =+ formula based on value in another column for variable rows

    Dear VBAers,

    Trying to insert either a sum formula like "=sum(c15+c18+c25) or =+c15+c18+c25 in VBA based on column Q which identities the variable rows with text as "TOT"

    This is my code and I admit I am challenged by this. Not sure how to code the variable part. I do not want a sumifs formula because I need to delete column Q after inserting the formula.

    With Worksheets("REPORT")

    Dim Rws3 As Long, Rng3 As Range, c3 As Range
    Rws3 = Cells(Rows.Count, "Q").End(xlUp).Row
    Set Rng3 = Range(Cells(2, "Q"), Cells(Rws3, "Q"))
    For Each c3 In Rng3.Cells
    If c3 = "INS" Then c3.Offset(0, -14).Formula = "=sum(C" & ?????????? & ")"
    Next c3


    End With

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Hello SteveM99,

    Can you post the worksheet for reference? Ideally, posting the complete workbook would be best.
    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

Posting Permissions

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