Consulting

Results 1 to 2 of 2

Thread: Copying data from another Workbook row wise

  1. #1

    Post Copying data from another Workbook row wise

    Hi guys!

    Wanted to copy data values from one workbook to another in a worksheet column wise I came up with the following code and it is working
    Sub copy()
    Dim wbMain As Workbook
    Dim wbData As Workbook
    
    Set wbMain = ActiveWorkbook
    Set wbData = Workbooks.Open("C:\Users\Naveed\Desktop\Excel Project\Test\Data.xlsx")
    
    wbData.Sheets(1).Range("A1:A5").copy
    wbMain.Sheets(1).Range("A1:A5").PasteSpecial
    End Sub
    But now i want to copy data row wise
    for instance values in the data workbook is stored on a range B21, C21, D21, E21..... up to AF21. how to copy that range to the Main workbook.

    To answer your question... yes I have two different workbooks, Main and Data. Main has the button on its sheet(1) and i want to copy data from sheet(1) on workbook Data

    my attempt
    'source copy range
    wbData.Sheets(1).Range("B21:AF21").Copy
    
    'destination paste range
    wbMain.Sheets(1).Range("B1").PasteSpecial xlPasteValues
    But every time I run the code it shows the dotted rectangle around the range how to remove it?

    Any help would be appreciated
    BR
    Last edited by Eva_Johansso; 12-15-2013 at 12:19 PM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Did the copy work, and you just want to get id of those dots? If so

    Application.CutCopyMode = False
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •