Results 1 to 1 of 1

Need help in in syntax to add formula to an existing formula

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-27-2007
    Posts
    106

    Need help in in syntax to add formula to an existing formula

    Hi

    Thanks to all that have helped me from the forum so far. I need a bit more help - I've got:

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
         With Target
            If .Column = 1 Then
                .Offset(, 1) = Now
                .Offset(, 2) = "1"
            Dim Cell As Range
            For Each Cell In Target
                If Cell.Column = 1 Then
                    If Application.CountIf(Columns(7), Cell) = 0 Then
                        Cells(Cells.Rows.Count, 7).End(xlUp).Offset(1, 0) = Cell
                        Cells(Cells.Rows.Count, 7).End(xlUp).Offset(0, 1).FormulaR1C1 = "=SUMIF(C[-7],RC[-1],C[-5])"
                    End If
                End If
            Next Cell
            End If
         End With
    End Sub
    In which the second part of the code i.e. from Dim Cell - populates column "G" with the unique user input value from Col "A" and then the total (using the SUMIF) is populated in Col "H" for the corresponding unique value.

    The other codes that I have are:

    Application.Index(Worksheets("REF PAGE").Range("$K:$K"), WorksheetFunction.Match(Target.Value, Worksheets("REF PAGE").Range("$A:$A"), 0))
    Application.Index(Worksheets("REF PAGE").Range("$B:$B"), WorksheetFunction.Match(Target.Value, Worksheets("REF PAGE").Range("$A:$A"), 0))
    These drag the values from my reference page, based on my Target.value from Col "A"

    So the question is - what is the correct syntax - to combine the formulas to:
    populate col "G" and "H" using the Dim Cell, then use the application.index formulas to relate to the unique value in col "G" and populate Col "I" and "J"? Is it just a case of changing "Target.value" in the application codes?

    I.E.

    Col A - User input
    Col B - date of input
    Col C - qty of input (defaulted to 1)
    Col G - Auto list of unique values of col "A"
    Col H - Sumif values
    Col I - application to index/match range $K:$K from ref page based on value in Col "G"
    Col J - application to index/match range $B:$B from ref page based on value in Col "G"

    All help will be much appreciated.
    Last edited by tony0710; 03-08-2009 at 07:11 AM.

Thread Information

Users Browsing this Thread

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

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