Results 1 to 5 of 5

Thread: Vba open workbook and paste from another workbook

  1. #1

    Vba open workbook and paste from another workbook



    Register for a FREE account, and/
    or Log in to avoid these ads!

    hi can you please help me with this code keep getting the error "object variable or with variable not set"

    many thanks

    Code:
    
    test() 
     
    Dim fname As String 
    Dim fpath As String 
    Dim owb As Workbook 
     
    fname = "DummyXXAC.xlsm" 
    fpath = "C:\Users\USER\Desktop" 
    owb = Application.Workbooks.Open(fpath & "\" & fname) 
     
     
    Windows("CNAV.xlsm").Activate 
    Set rngcopy = Sheets("Raw data").Range("A1:IV1").Find("Ccy", LookIn:=xlValues) 
    Set rngcopy = Range(rngcopy.Offset(1, 0), Cells(Rows.Count, rngcopy.Column).End(xlUp)) 
    Set rngPaste = Workbooks(DummyXXAC.xlsm).Sheets("Sheet1").Range("d2") 
    rngcopy.Copy 
    rngPaste.PasteSpecial xlPasteValues 
    rngPaste.PasteSpecial xlPasteFormats

  2. #2
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,829
    Articles
    0
    Excel Version
    O365
    Which line errors?

  3. #3
    Quote Originally Posted by Bob Phillips View Post
    Which line errors?

    Hi Bob, Thanks for your reply i actually figured it out and solved it, many thanks

  4. #4
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    824
    Articles
    0
    Excel Version
    Excel 2010
    i actually figured it out and solved it
    Are you sure YOU figured it out and it wasn't p45cal that told you ?

  5. #5
    hi bob,

    yes p45cal helped me a lot thanks so much and i have added more code to it thanks a lot

Posting Permissions

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