+ Reply to Thread
Results 1 to 11 of 11

Error 438

  1. #1
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Error 438

    I had help with a code to past values from one sheet to another and it worked for a few days but now I'm getting an error 438. The interesting thing is the almost exact same code on the same page works. And a similar code on a different sheet works fine. I cant figure out why its happening. Ill attach the workbook. If you hit the "protocol" button at A1 on the Coherence page you get the 438 error. If you hit the "protocol" button on the phase page it works fine.


    This is the code
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It errors on the first "ws1.Cells(j, 22).PasteSpecial xlPasteValues" but if i delete that one and just have the second one it works fine... all that to say im very confused.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Error 438

    Your Problem is Obvious to me.

    Send me £100 and I will tell you. LOL.

    No seriously.

    If you had put ypur macro into a normal macro module it would have worked/

    You didn't, the code is in a worksheet macro module.

    A Worksheet Macro Module can only make changes in that worksheet.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: Error 438

    ok 2 questions then. why did it work for 2 days? and how do i move it to a module? I see i have 7 modules on the workbook which one do I put it on? Sorry if its a silly question, its all new to me. Ok 3 questions. If I just delete the first For statement the second one operates fine and its almost identical.

    Thoroughly confused Kevin
    Last edited by kevinu; 05-25-2017 at 04:41 PM.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Error 438

    If you select the developer tab and then visual basic

    Visual basic opens.


    Select View and then Project Explorer

    You will See a list of all your open workbooks.

    Eg:

    VBA Project(Book1)
    Module1
    Sheet1(Useful Code)
    Sheet2(Sheet1)
    ThisWorkbook

    If you select insert, you can add Modules and Userforms.

    If you double click on a sheet or module name that Macro module will open for editing.
    If you double click on "This workbook" then the Workbook Macro Module will open.
    Any macro here will work like a sheet specific macro module but will run on every sheet.



    I had a fresh look at your workbook and changed the Workbook Macro to:-

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 05-25-2017 at 05:43 PM.

  5. #5
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: Error 438

    thanks for the code edit. I put the commandbutton_2 click code in the workbook module but it didnt change anything. I think I'm getting it wrong still. If I edit the button code to just do the 2nd For statement without the first it works fine. So is the issue where the code is? The code is pulling from 2 different columns and it seems the first one is the issue. Again, sorry for the noob questions. If its possible could you get the example sheet to work. Then I could copy the changes to the original.
    Last edited by kevinu; 05-25-2017 at 07:21 PM.

  6. #6
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: Error 438

    ok its fixed... but how i fixed it is stupid. I wrote the code again under the second For statement.. then erased the original... now it works ??????

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Error 438

    Last edited by MarvinP; 05-25-2017 at 08:25 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: Error 438

    thanks for the resource

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

    Re: Error 438

    The only problem with the code in the workbook is a typo here,
    Please Login or Register  to view this content.
    where pastspecial should obviously be PasteSpecial.

    Note, you can change other worksheets from within a worksheet module - you just need to reference everything properly.
    If posting code please use code tags, see here.

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Error 438

    SERIOUSLY????!!!! kevinu, you FIXED the problem BEFORE pasting the code in your original post! I stared at that for 45 minutes, not wanting to download a wonky macro.
    Last edited by leelnich; 05-26-2017 at 02:16 AM.

  11. #11
    Forum Contributor
    Join Date
    03-10-2017
    Location
    USA
    MS-Off Ver
    office 2016
    Posts
    393

    Re: Error 438

    Leelnich sorry the fix was totally an a shot in the dark. I just saw that the second For statement worked so I rewrote it with the ranges in the first one and rewrote a new second one and somehow it worked. In the original program the code was spelled correctly but in the example I must have messed it up. sorry for the error on my part. I also thought i was supposed to post in a new topic as it was a new problem. I thought i referenced it in that post. My bad

+ 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. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  2. [SOLVED] Run-tim error -2147467259(80004005): Automation error Unspecidied error
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2014, 12:12 PM
  3. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  4. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  5. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  6. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  7. Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 PM

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