+ Reply to Thread
Results 1 to 29 of 29

run time error 91 problem

  1. #1
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690

    run time error 91 problem

    hi gents
    just a small issue

    i have this fantastic piece of code by protonleah which works
    Please Login or Register  to view this content.
    this works perfectly

    i then try to add my save to specific folder code and i get an error

    Please Login or Register  to view this content.
    could anyone point me straight please

    the way i have it set out is
    Please Login or Register  to view this content.
    and i get run time error 91
    object variable or with block variable not set
    i click the debug button
    and in yellow is this line

    Please Login or Register  to view this content.
    Last edited by stevesunfold; 10-22-2008 at 05:33 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    The variable PONUMBER appears to be a Range. I don't see in the code where this variable is set or declared. That's why you're getting the error. Use the Option Explicit statement as the first line of your module. This will tell you when a variable hasn't be declared.

    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 10-21-2008 at 03:53 PM.

  3. #3
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith and thanks for the reply

    i put option explicit as the top line but im still getting the same error

    can you help please?

    regards

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    From where is the varaible PONUMBER supposed to be getting assigned? In other words, where in your code is PONUMBER defined?

  5. #5
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi jason im not sure what you mean to be honest as most people on here are aware my coding knowledge is minimal to none

    im capable in smaller tasks on excel but coding is not good

    both codes were done for me by other people

    i want to intergrate the two codes so they work in one command button

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    Can you post the workbook for review? Seeing all the workbook's code will help resolve your problem.

    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    no problem leith

    cell b69 and b70 are the address for the directories which have no issue problems and works when i input the correct address
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    The werea couple of problems. The range POnumber is a named range on "Pruchase Order". It is actually cell $K$12. This cell also has a custom format that adds "ST " to the PO number. You had this in your code...
    Please Login or Register  to view this content.
    What that line should be is...
    Please Login or Register  to view this content.
    Another problem was a public variable PONUMBER was declared as a Range. This created a naming conflict between the named range and the public variable. I have made all the changes, but haven't run the code. Test out the attached workbook and let me know how it works.

    Sincerely,
    Leith Ross
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith
    and thanks for your efforts
    im getting run time error 424
    object required

    if i click the debug
    it highlights this line

    PORow = PONUMBER.Value + 1

  10. #10
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    im sorry i didnt put in the destination address into b69 and b70

    im guessing you understand what i want it to do

    i want it to open as a purchase order with them number already in the cell
    i then want it to print 2 copies
    it then has to save it in the folder as determined by the address in cell b69 or b70
    it then looks for the folder as per cell ref g23
    and saves it there

    it then clears all the cells i need cleared

    and then shows the next available po number

  11. #11
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    ive merged the two codes

    and getting run time error 424 object required

    again i press the debug and it highlights this

    PORow = PONUMBER.Value + 1

    here is my full code
    Please Login or Register  to view this content.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    Are you using the updated file? I set up folders on my hard drive to test the macro and it works fine. What macro are you running?

    Sincerely,
    Leith Ross

  13. #13
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    find attached
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    leith

    in b69 i have

    C:\Documents and Settings\my name\Desktop\master documents\job folder

    in b70 i have

    C:\Documents and Settings\my name\Desktop\master documents\stock purchase orders

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    Ok, this version should work.

    Sincerely,
    Leith Ross
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith

    and thanks for your continued support

    no errors but its not saving in the destination folders

  17. #17
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    does module1 and the Sub SaveJobFile() not have to be merged together as one code to get the results i want?

  18. #18
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    also noted that when i implement the save sheet on its own it works

    but doesnt save with st infront of the order number

    i did have this code

    Please Login or Register  to view this content.
    and now yours says

    Please Login or Register  to view this content.

  19. #19
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    My mistake on the "ST" piece. Change the code line to...
    Please Login or Register  to view this content.
    As for the parts, I will have to examine that further.

    Sincerely,
    Leith Ross

  20. #20
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    leith that line has worked perfectly

    i just thought i could merge the 2 codes together but it doesnt seem as simple as that

  21. #21
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    If you want, you can cut and paste all of the macro code from Purchase Order (Sheet1) and paste it into Module1. Then all your macros will be available to any other part of your VBA project and in one place.

    Sincerely,
    Leith Ross

  22. #22
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith i have tried that but thats when the problems start

    if i run the print button it does as i want

    and if i run the sae button it does what i want but when i merge the two is when i get problems

  23. #23
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    trying to get the two to run together is a nightmare
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    i want to make the print and copy button do it all

  24. #24
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    The attached workbook has been updated to run both macros once the Copy button is clicked.

    Sincerely,
    Leith Ross
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith
    your help is gratefully appreciated
    i am getting no errors at all and it is saving ,but, its not saving to where it should be!!
    and i cant find where it is saving to

  26. #26
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    i have a folder on my desktop
    its called master documents
    C:\Documents and Settings\steve taylor\Desktop\master documents

    inside that folder i have a subfolder called job folder
    and another called stock purchase orders

    b69 = C:\Documents and Settings\my name\Desktop\master documents\job folder

    b70 = C:\Documents and Settings\my name\Desktop\master documents\stock purchase orders

    and it should search for one of them folders to go into

  27. #27
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    leith
    i have found the problem but not sure why its doing it

    first of all its saving the file as the purchase number as the next generated number as opposed to the one it should be

    ie

    its doing the macro
    and printing
    its then clearing the cells
    then saving

    so in effect
    its opening as lets say st010
    printing
    clearing cells
    then saving as st011

    which is obviously wrong

    it should be doing the macro
    then printing
    then saving
    then clearing the cells and going to the next number


    thanks so so much

  28. #28
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello stevesunfold,

    I ran this version of the workbook. The execution now follows as you outlined in your last post.

    Sincerely,
    Leith Ross
    Attached Files Attached Files
    Last edited by Leith Ross; 10-22-2008 at 06:02 PM. Reason: Correct error in CopyandPrint macro

  29. #29
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi leith
    what can i say except thanks so so much
    i have sent you a personal message so please take the time to read it
    this problem is now over
    it really is appreciated
    everyone who has helped thank you so much

+ 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