+ Reply to Thread
Results 1 to 13 of 13

Checking Columns and Adding For Non Existing Data

Hybrid View

  1. #1
    Registered User
    Join Date
    09-17-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    13
    This post has been deleted.

    Thank you for your understanding.
    Last edited by pterodactyl; 09-25-2011 at 01:57 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Checking Columns and Adding For Non Existing Data

    Try this

    Sub SaveScore()
    
    Dim RW As Long, rFind As Range, rComp As Range
    
    If Worksheets("Orders").Range("C6") <> False Then
        MsgBox "Please create a new one!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    If Worksheets("Orders").[D6] <> "Complete" Then
        MsgBox "Please enter all data!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    Set rComp = Sheets("Companies").Range("C17").CurrentRegion
    rComp.Sort Key1:=rComp(1, 1), Order1:=xlAscending, header:=xlGuess
    With rComp.Columns(1)
        Set rFind = .Find(What:=Range("Company"), LookIn:=xlFormulas, _
                              LookAt:=xlWhole, SearchOrder:=xlByRows, _
                              SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        If Not rFind Is Nothing Then
            RW = rFind.Row
        Else
            Call AddNewCustomer(Range("B7"))
            'MsgBox "Please create a new customer!", vbOKOnly + vbExclamation, "Warning"
            Exit Sub
        End If
    End With
    
    If Worksheets("Orders").[D23] = 0 Then
        MsgBox "Please enter product quantities!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    With Worksheets("Companies")
        .Range("D" & RW) = Worksheets("Orders").[Name]
        .Range("I" & RW) = .Range("I" & RW) + Worksheets("Orders").[D25]
        .Range("J" & RW) = Worksheets("Orders").[Invoice]
    End With
    
    
    'Haven't touched section below except to tidy up a little
    With Sheets("Orders")
        .Range("D34") = .Range("D34") + .Range("D17")
        .Range("F34") = .Range("F34") - .Range("D17")
        .Range("D35") = .Range("D35") + .Range("D18")
        .Range("F35") = .Range("F35") - .Range("D18")
        .Range("D36") = .Range("D36") + .Range("D19")
        .Range("F36") = .Range("F36") - .Range("D19")
        .Range("D37") = .Range("D37") + .Range("D20")
        .Range("F37") = .Range("F37") - .Range("D20")
        .Range("D38") = .Range("D38") + .Range("D21")
        .Range("F38") = .Range("F38") - .Range("D21")
    End With
    End Sub
    
    
    
    
    Sub getShapeProc()
        'List of buttons/shapes ON THE worksheets
    
    End Sub
    
    Sub AddNewCustomer(NewCustomer As String)
    Sheets("Companies").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0) = NewCustomer
    Set rComp = Sheets("Companies").Range("C17").CurrentRegion
    rComp.Sort Key1:=rComp(1, 1), Order1:=xlAscending, header:=xlNo
    End Sub
    Martin

  3. #3
    Registered User
    Join Date
    09-17-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Checking Columns and Adding For Non Existing Data

    This post has been deleted

    Thank you for your understanding.
    Last edited by pterodactyl; 09-25-2011 at 01:58 AM.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Checking Columns and Adding For Non Existing Data

    Try

    Sub SaveScore()
    
    Dim RW As Long, rFind As Range, rComp As Range
    
    If Worksheets("Orders").Range("C6") <> False Then
        MsgBox "Please create a new one!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    If Worksheets("Orders").[D6] <> "Complete" Then
        MsgBox "Please enter all data!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    Set rComp = Sheets("Companies").Range("C15").CurrentRegion
    If rComp.Count <> 1 Then rComp.Sort Key1:=rComp(1, 1), Order1:=xlAscending, header:=xlYes
    With rComp.Columns(1)
        Set rFind = .Find(What:=Range("Company"), LookIn:=xlFormulas, _
                              LookAt:=xlWhole, SearchOrder:=xlByRows, _
                              SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
        If Not rFind Is Nothing Then
            RW = rFind.Row
        Else
            Call AddNewCustomer(Range("B7"))
            'MsgBox "Please create a new customer!", vbOKOnly + vbExclamation, "Warning"
            Exit Sub
        End If
    End With
    
    If Worksheets("Orders").[D23] = 0 Then
        MsgBox "Please enter product quantities!", vbOKOnly + vbExclamation, "Warning"
        Exit Sub
    End If
    
    With Worksheets("Companies")
        .Range("D" & RW) = Worksheets("Orders").[Name]
        .Range("I" & RW) = .Range("I" & RW) + Worksheets("Orders").[D25]
        .Range("J" & RW) = Worksheets("Orders").[Invoice]
    End With
    
    
    'Haven't touched section below except to tidy up a little
    With Sheets("Orders")
        .Range("D34") = .Range("D34") + .Range("D17")
        .Range("F34") = .Range("F34") - .Range("D17")
        .Range("D35") = .Range("D35") + .Range("D18")
        .Range("F35") = .Range("F35") - .Range("D18")
        .Range("D36") = .Range("D36") + .Range("D19")
        .Range("F36") = .Range("F36") - .Range("D19")
        .Range("D37") = .Range("D37") + .Range("D20")
        .Range("F37") = .Range("F37") - .Range("D20")
        .Range("D38") = .Range("D38") + .Range("D21")
        .Range("F38") = .Range("F38") - .Range("D21")
    End With
    End Sub
    
    
    
    
    Sub getShapeProc()
        'List of buttons/shapes ON THE worksheets
    
    End Sub
    
    Sub AddNewCustomer(NewCustomer As String)
    Sheets("Companies").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0) = NewCustomer
    Set rComp = Sheets("Companies").Range("C15").CurrentRegion
    rComp.Sort Key1:=rComp(1, 1), Order1:=xlAscending, header:=xlYes
    End Sub
    I've removed the blank row 16 on the Customer sheet which makes things easier.

  5. #5
    Registered User
    Join Date
    09-17-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Checking Columns and Adding For Non Existing Data

    This post has been deleted.

    Thank you for your understanding.
    Last edited by pterodactyl; 09-25-2011 at 01:59 AM.

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Checking Columns and Adding For Non Existing Data

    Your attachment appears to have disappeared from the thread - can you reattach?

  7. #7
    Registered User
    Join Date
    09-17-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Checking Columns and Adding For Non Existing Data

    This post has been deleted.

    Thank you for your understanding.
    Last edited by pterodactyl; 09-25-2011 at 02:04 AM.

  8. #8
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Checking Columns and Adding For Non Existing Data

    I'm not sure how close I am to what you are after but please have a look at the attached.

    A new row is created in the companies table when a novel value is added. I've also added a bit of functionality to pull in details for existing customers.

    Please have a play with it and see what else needs doing.

  9. #9
    Registered User
    Join Date
    09-17-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Checking Columns and Adding For Non Existing Data

    This post has been deleted.

    Thank you for your understanding.
    Last edited by pterodactyl; 09-25-2011 at 02:05 AM.

  10. #10
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Checking Columns and Adding For Non Existing Data

    Here it is. Sorry about that.
    Attached Files Attached Files

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Checking Columns and Adding For Non Existing Data

    Why have you deleted all your posts? Its tough to find out what is the problem.

+ Reply to Thread

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