+ Reply to Thread
Results 1 to 3 of 3

Having troubles using visual basic to paste info from one workbook to another

  1. #1
    Registered User
    Join Date
    11-15-2004
    Posts
    22

    Having troubles using visual basic to paste info from one workbook to another

    I'm trying to paste info from one workbook to another, but don't know much about writing macros. I'm just adjusting another macro to do what I need it to do. Here is the working macro I have so far:

    Dim Markone As String
    Dim Marktwo As String
    Dim Markthree As String
    Dim Markfour As String
    Dim Markfive As String
    Dim NewRow As String

    Markone = Range("A12").Value
    Marktwo = Range("A13").Value
    Markthree = Range("A14").Value
    Markfour = Range("A15").Value
    Markfive = Range("A16").Value

    With Worksheets("GIRDER")
    .Cells(12, 1).Value = Markone
    .Cells(14, 1).Value = Marktwo
    .Cells(16, 1).Value = Markthree
    .Cells(18, 1).Value = Markfour
    .Cells(20, 1).Value = Markfive

    End With

    End Sub

    I tried typing in "With Workbook("NEW_BOM")" above the "With Worksheets("GIRDER")" But didn't work. The macro works fine in the same workbook, but just don't know what to type in to make it go to the other workbook named "BOM_NEW".

    Any help is appreciated.

  2. #2
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    i am assuming that NEW_BOM.xls is the workbook to which you want to copy the values.

    And macro is in the workbook from which you want to copy.

    NEW_BOM.xls file has to be opened for this macro to work or alternately you can write to open it and execute this macro.



    Dim Markone As String
    Dim Marktwo As String
    Dim Markthree As String
    Dim Markfour As String
    Dim Markfive As String
    Dim NewRow As String
    Markone = Range("A12").Value
    Marktwo = Range("A13").Value
    Markthree = Range("A14").Value
    Markfour = Range("A15").Value
    Markfive = Range("A16").Value
    With Workbooks("NEW_BOM.xls").Worksheets("GIRDER")
    .Cells(12, 1).Value = Markone
    .Cells(14, 1).Value = Marktwo
    .Cells(16, 1).Value = Markthree
    .Cells(18, 1).Value = Markfour
    .Cells(20, 1).Value = Markfive

    End With

    End Sub

  3. #3
    Registered User
    Join Date
    11-15-2004
    Posts
    22
    Thank you! Was missing the .xls

+ 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