+ Reply to Thread
Results 1 to 32 of 32

Form a customer list from invoices

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Form a customer list from invoices

    I'm trying to figure out a way to get my invoice templates to copy the names and addresses from them to another worksheet to form a customer database if you will.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Form a customer list from invoices

    Can you supply a sample workbook, so somebody can help you?

  3. #3
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by davesexcel View Post
    Can you supply a sample workbook, so somebody can help you?

    Sorry about the repeat post.

    These are the two workbooks:

    Customer Details.zip

    Proposal.zip

    (Hope I did this right.)

  4. #4
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Anyone please?

  5. #5
    Valued Forum Contributor khamilton's Avatar
    Join Date
    10-08-2009
    Location
    IL
    MS-Off Ver
    Excel 2007
    Posts
    345

    Re: Form a customer list from invoices

    Are you going to have every proposal on a different tab in the proposal workbook?

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Form a customer list from invoices

    Try this out, Ensure both workbooks are open, click the button in Proposal1 to send the data to Customer Details.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by davesexcel View Post
    Try this out, Ensure both workbooks are open, click the button in Proposal1 to send the data to Customer Details.

    Thanks Dave, however I get an error message:
    Run-time error '9':
    Subscript out of range


    how do I debug this?

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Form a customer list from invoices

    Quote Originally Posted by coffcons View Post
    Thanks Dave, however I get an error message:
    Run-time error '9':
    Subscript out of range


    how do I debug this?
    Are both workbooks open?

  9. #9
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by davesexcel View Post
    Are both workbooks open?

    Yes. I opened both of the ones you sent.

  10. #10
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by khamilton View Post
    Are you going to have every proposal on a different tab in the proposal workbook?
    No. Each one will be on a separate workbook and saved separately.

  11. #11
    Registered User
    Join Date
    11-20-2009
    Location
    England
    MS-Off Ver
    Excel 2010 @ Work and Excel 2007 @ Home
    Posts
    10

    Re: Form a customer list from invoices

    I get subscript out of range too, I'm using xl2002. If I change the code to this it works:

    Sub SendData()
    
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Name")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 1) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Phone")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 2) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Address")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 3) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("City")
    
    End Sub
    edit: too slow! I see you got there already.

  12. #12
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by Coder View Post
    I get subscript out of range too, I'm using xl2002. If I change the code to this it works:

    Sub SendData()
    
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Name")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 1) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Phone")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 2) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("Address")
        Workbooks("Customer Details.xls").Worksheets("Sheet1").Range("A65536").End(xlUp).Offset(0, 3) = Workbooks("Proposal1.xls").Worksheets("Sheet1").Range("City")
    
    End Sub
    edit: too slow! I see you got there already.


    Yes, exactly! That's precisely what I did. That gets it to find the workbooks but now I'm trying to better identify the proper cells.

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Form a customer list from invoices

    Quote Originally Posted by coffcons View Post
    Yes, exactly! That's precisely what I did. That gets it to find the workbooks but now I'm trying to better identify the proper cells.
    LOL, I had named the ranges to the cells in the Company header, if you click on the Company Header, Select the Company name and you will see the name of the cell is "Name", Click on the Phone Number and you will see the cell is named "Phone". That is what is getting transferred to the other Workbook.

    If you go to Insert=>name=>define Click on one of the names and change the cell reference to the cell reference you want.

    Sorry for the confusion.

  14. #14
    Registered User
    Join Date
    11-24-2007
    Posts
    43

    Re: Form a customer list from invoices

    Quote Originally Posted by davesexcel View Post
    LOL, I had named the ranges to the cells in the Company header, if you click on the Company Header, Select the Company name and you will see the name of the cell is "Name", Click on the Phone Number and you will see the cell is named "Phone". That is what is getting transferred to the other Workbook.

    If you go to Insert=>name=>define Click on one of the names and change the cell reference to the cell reference you want.

    Sorry for the confusion.


    Thanks Dave,

    I figured that out and got it all to work properly. Thanks for getting me set up with that code.

    I wonder if you have any ideas about my other question. Namely that I would prefer to be able to save each new 'proposal1' form under a more specific name in that particular customer's folder. Is there a function that allows for this?

    Perhaps 'ThisWorkbook' or "ActiveWorkBook" functions?
    Last edited by coffcons; 11-22-2009 at 06:08 PM.

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Form a customer list from invoices

    I believe this should work for you. This will create a Subfolder in a folder named "CustomerTest", which will already exist.
    Sub SendData()
    
        Dim wb1 As Workbook, wb2 As Workbook, ws1 As Worksheet, ws2 As Worksheet
        Set wb1 = Workbooks("Proposal1")
        Set wb2 = Workbooks("Customer Details")
        Set ws1 = wb1.Worksheets("Sheet1")
        Set ws2 = wb2.Worksheets("Sheet1")
    
        ws2.Range("A65536").End(xlUp).Offset(1, 0) = ws1.Range("Name")
        ws2.Range("A65536").End(xlUp).Offset(0, 1) = ws1.Range("Phone")
        ws2.Range("A65536").End(xlUp).Offset(0, 2) = ws1.Range("Address")
        ws2.Range("A65536").End(xlUp).Offset(0, 3) = ws1.Range("City")
    
        ChDir "C:\CustomerTest"
        On Error Resume Next
        MkDir (Range("A10").Text)
        ActiveWorkbook.SaveAs Filename:="C:\CustomerTest\" & Range("A10") & "\Proposal1.xls"
        
    End Sub

+ 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