+ Reply to Thread
Results 1 to 9 of 9

RunTime Error 438

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    Lagos
    MS-Off Ver
    Excel 2007
    Posts
    67

    RunTime Error 438

    Hi Guys,

    I need your help, on VBA code below. My aim is to be able to copy a range from one workbook to another and I get the Run Time Error 438 on the line colored red.

    Can this code be corrected or is there an easier way to get this done?

    Thanks.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: RunTime Error 438

    Please Login or Register  to view this content.
    Should have a worksheet name.
    wbTarget is a workbook, so need to add the sheet within in the workbook
    Like
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-21-2012
    Location
    Lagos
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: RunTime Error 438

    Thanks AB33,

    It worked perfectly. I have one more question though. What if I want to modify this code in such a way that when it runs, I would have the open dialog box to select the excel workbook I want to paste my data into. This would help in the sense that I would want to copy a range to separate workbooks at different times.

    Thanks again.
    Last edited by akynyemi; 02-17-2014 at 03:38 AM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTime Error 438

    Why not replace this code,
    Please Login or Register  to view this content.
    with this?
    Please Login or Register  to view this content.
    And this,
    Please Login or Register  to view this content.
    with this.
    Please Login or Register  to view this content.
    As for a dialog for selecting the file, you could use Application.GetOpenFilename.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    02-21-2012
    Location
    Lagos
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: RunTime Error 438

    Thanks Norie for taking time out, it worked perfectly.

    Regards.

  6. #6
    Registered User
    Join Date
    02-21-2012
    Location
    Lagos
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: RunTime Error 438

    Hi Norie,

    I modified my code further in such a way that if no file is selected, it displays a message and then exits. But I have another Runtime Error 13 "Type Mismatch on "If strFileName = False Then"

    My full code is below.


    Thanks.
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: RunTime Error 438

    strFileName is string therefore you must compare to "False" not False. or preferably use a Variant rather than String.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: RunTime Error 438

    Izandol is right you need to use "False".

    By the way, all that activating/selecting isn't needed.

  9. #9
    Registered User
    Join Date
    02-21-2012
    Location
    Lagos
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: RunTime Error 438

    Thanks Guys.

    Regards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  2. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  3. Defining Array - Runtime error 9, Subscript out of range error
    By MaartenW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2012, 07:32 AM
  4. runtime error 3265 error in a VBA Query to pull info from ERP Database
    By NBVC in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-12-2010, 03:59 PM
  5. Excel xmlHTTP object error message - system/runtime error
    By Porky2007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2007, 09:36 AM

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