+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    sorry for the title, that was my best way to try to explain in a short way !

    Here is my problem:
    1- On workbook1, I have created a Work order page and I want the Cell I2 to change number every time I open the file.

    2- On workbook2, I have created a Sheet the will keep track of some information of Workbook1.
    Cell: A8,I6,I8,A13,I2 (information are: Date, Customer, Engine, Serial, Problem, Work Order Number)

    here is what I have done so far by finding some of my answer on forums (I never used macro before):

    I almost work, the problem is that when saving on exiting it will save all the right informations that I want except the Work Order Number (cell I2); it is 1 number behind

    Private Sub Workbook_Open()
    Range("i2").Value = Range("i2").Value + 1




    Dim sh1 As Worksheet, sh2 As Worksheet, v As Variant, i As Long, j As Long
    Dim rw As Long

    Set sh1 = Worksheets("W1")
    Set sh2 = Worksheets("W2")

    v = Array("A8", "E2", "I6", "I8", "A13", "I2")

    i = 1
    rw = sh2.Cells(Rows.Count, "A").End(xlUp).Row + 1
    For j = LBound(v) To UBound(v)
    sh1.Range(v(j)).copy sh2.Cells(rw, i)
    i = i + 1

    Next j
    End Sub

    Many thanks for your help

  2. #2
    Forum Guru Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    Cheshire, UK
    MS-Off Ver
    MS 97, 2003, 2007, 2010
    Posts
    2,900

    Re: Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    Which workbook is this code in? are you collecting I2 from the newly opened workbook in to the already open workbook?, if so you need to qualify your range properly. Some sample workbooks would be good.

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    can I send the file so you can have a look at it ?
    It is in french but you would see how it work !

  4. #4
    Registered User
    Join Date
    03-10-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    I have put the file lower in the post !
    Last edited by martman; 03-12-2010 at 08:34 AM.

  5. #5
    Forum Guru Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    Cheshire, UK
    MS-Off Ver
    MS 97, 2003, 2007, 2010
    Posts
    2,900

    Re: Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    martman, please save your workbook as an xls (97-2003) as most people do not have 2007 yet, i'm at work and i do not have excel 2007 here

  6. #6
    Registered User
    Join Date
    03-10-2010
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need help Copy data from workbook1 to workbook 2 + 1 cell changing number on open

    here is the file saved in 97-2003 format !
    Attached Files Attached Files

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.2.0