+ Reply to Thread
Results 1 to 28 of 28

Run-time error ' 1004 ': Application-defined or object-defined error

  1. #1
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Run-time error ' 1004 ': Application-defined or object-defined error

    I am attempting to write a program to sort the local bowls teams, randomize the names & print the players score cards. The sorting macro and printing programs are working, but the randomizing macro is tossing up the above error msg at the 1st list.

    The sheet headings; A1: Surname,Christian, Posit (position), Surname, Christian, Posit, Surname, Christian, Posit, Rink

    I have been trying to insert a column at A1; use =RAND & fill to the bottom of the first names list; copy & paste as values. Am using the macro generator (a bit long in the tooth for VBA).

    I will then delete the added column & move to the next Surname list to repeat the process and once again for the players position in a team.

    Please Login or Register  to view this content.
    Hope this is enough info (waffle)
    Thank you in advance
    Muzza1
    Last edited by Muzza1; 07-25-2015 at 04:18 PM. Reason: Mistake in program operation description

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    13,000

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Please edit your post, the ending code tag is wrong. Its just [/code] not [/end code]
    Ben Van Johnson

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    It's a recorded macro. There are hard coded offsets and I suspect that is the problem. I have no data to test but, if there are less than 15 rows, this will fail:

    Please Login or Register  to view this content.
    You would be better determining and storing the row number of the last data record and using that in your offset, adjusted where necessary.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Hi TMS
    You are correct. Rechecked the code and your code line highlighted. The number of players will vary on the day of play. How can I hand this program over to someone else as a going concern if we have to change this Offset. Is there another fix?

    Muzza1

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Please Login or Register  to view this content.

    Regards, TMS

  6. #6
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Hi TMS

    Have attached a file Start triples7.xslm. IF you open it & press MOVE PLAYERS I think you will see what I am trying to acheive. I intend copying your column A1 to new columns at R1C5 & R1C9. Copy/paste values for each & then sort delete columns in turn. Think this will work?

    Your assistance very much appreciated cobber (Aussy expression)

    Muzz1

  7. #7
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Think I missed the attachment
    Attached Files Attached Files

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    So, the plan is to insert a column before column 5 (Surname (1)), and another before what would then be column 9 (Surname (2)) and generate random numbers in each one so that each set of names can be sorted? Although the numbers would be random, I'm guessing there's no guarantee that some, perhaps many, of the names will come out in the same sequence such that you have people playing against themselves.

  9. #9
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Hi TMS

    The oldies, (myself included) in column 1 (Surname) play as leads. The Surname column 5 play as 2nds. The surname column 9 play as Skips. The idea is to put the players randomly into different teams and have them play on different rinks with each game. They stay playing in the same position with different partners.

    Go MU
    Muzza1

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    OK, try this:

    Please Login or Register  to view this content.

    Regards, TMS

  11. #11
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Wilco Biggles

    Muzza1

  12. #12
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Surname Christian Position Surname Christian Position Surname Christian Position Rink Count y = #REF!
    Abad Deanna L Blackaby Silver Fred L Wilson Catherine L 1 CHECK ALL NAMES ENTERED
    Brown Beverley L Buck Prentice Andrew L Lewis Judy L
    Burdett Kay L Burdett Crossley Fred L Letnic Beverley L 2
    Chidgey Carolina L Davis Simonsen Kevin L Watson Eric L
    Crossley Fred L Douglas Burdett Kay L Worling Alan L
    Letnic Beverley L Green Whan Leonard L Burdett Kay L 3 MANUALY SORT PLAYERS
    Lewis Judy L Hooper Letnic Beverley L Chidgey Carolina L
    Pearce Allan L McKay Chidgey Carolina L Whan Leonard L 4
    Prentice Andrew L McMullen Pearce Allan L Crossley Fred L
    Silver Fred L Nash Wallis Rae L Prentice Andrew L
    Simonsen Kevin L Norman Watson Eric L Brown Beverley L 5 PUT CARDS IN PRINTER
    Wallis Rae L Quelhurst Worling Alan L Abad Deanna L
    Watson Eric L Roehrig Abad Deanna L Pearce Allan L 6
    Whan Leonard L Voak Brown Beverley L Wallis Rae L
    Wilson Catherine L Walton Lewis Judy L Silver Fred L
    Worling Alan L Whaanga Wilson Catherine L Simonsen Kevin L THE CARDS GO UPSIDE-DOWN
    9
    9
    10
    10
    11
    11
    12
    12
    13
    13
    14
    14
    Hi TMS
    Got a problem. Copy of screen above. Its like the formating has been changed & columns 5 & 9 are misplaced. DUH
    Muzz1

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Can't look at it until later but your 'copy of screen' isn't very helpful. The code worked ok with your sample. Have you tried it with that? Your copy of screen Seems to be missing a column (4) (sheet)

  14. #14
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    I think I know what happened. I suspect you were couldn't/didn't run the sort players button. The players for the day put their names on a sheet. This is entered into the club members database in the program as a "y". After using this to sort the players into their positions the "sheet" column is deleted.

    I have added your latest to your previous, edited and compiled it. The program ran right thru but stopped with everything in almost the correct place. The rand results were not deleted. Am I wrong again! Thanks for your perseverance.
    Muzza1

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    The workbook you uploaded was a .xlsm file but there was no code in it. So, no, I couldn't click on any buttons. The code is designed assuming that it will insert columns at column H and column E.

    I'll have another look later and see if I can adjust it.

  16. #16
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    8.30 pm, offline till about mid day tomorrow. Look forward to possibly hearing from you then.

    Muzza1

  17. #17
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Please Login or Register  to view this content.

  18. #18
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Try:

    Please Login or Register  to view this content.

    Regards, TMS

  19. #19
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    The last tried code
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Off to city back about 2.00

  21. #21
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    I've posted later code than that. Why are you testing old versions of the code? We know they don't work if the sheet hasn't been processed.

    See this code and the sample workbook attached. I've added Conditional Formatting to highlight when a name is duplicated.

    Please Login or Register  to view this content.

    Regards, TMS
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    I have attached 3 x files.
    The 1st (Start triples data)shows the database ready to have the sheet names for the day selected with a "y".
    The 2nd (Start triples move) shows the program after the move players button is clicked.
    The 3rd (Start triples sInsertRandValues after I run macro sInsertRandValues.

    The first column has not sorted. The next 2 columns have sorted but the posit columns have been replaced with the lead posit info. ???

    Muzza1
    Attached Files Attached Files

  23. #23
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Ah, OK, I misunderstood your process. I guess it would have helped if you didn't keep posting .xlsm files with no code in them. It's not possible to work through the process step by step. I'd assumed that you populated the columns D:E and F:H from columns A:C.

    Comment out these two lines of code

    Please Login or Register  to view this content.
    Note the comments describing each section of code ...

    so you get:

    Please Login or Register  to view this content.

    The problem being that the code does/did exactly what I expected/intended it to do every time ... just not quite what you expected.

    Regards, TMS

  24. #24
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    And, if you want/need to sort all three blocks of data ...

    Please Login or Register  to view this content.

    Regards, TMS
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    The macro is now working. Can you give me the completed code as column A & B are not randomizing. I beleive that the first list of code that you sent needs to be edited into the front of you latest code?? This way we don't run the risk of me stuffing it up.
    Muzza1
    Last edited by Muzza1; 07-28-2015 at 05:35 AM.

  26. #26
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Posts may have crossed. See post #24.

  27. #27
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,047

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  28. #28
    Registered User
    Join Date
    05-09-2015
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    19

    Re: Run-time error ' 1004 ': Application-defined or object-defined error

    Hi TMS
    Yes the problem is solved. I realise that my lack of VBA knowledge and being new to the forum has not made it easy for you.

    Do you have a skype address, I would like to thank you in person and perhaps you would consider becoming my mentor with VBA. I am now, thanks to you, considering continuing my learning in this area. I thought this might be a good way to start.
    Thank you again for your guidance
    Muzz1

+ 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. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  3. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  4. [SOLVED] Run time error 1004 Application-Defined or Object-Defined Error - Placing data into next e
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-27-2014, 12:57 PM
  5. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  6. [SOLVED] Macro causes Run time error 1004 Application defined or object-defined error
    By Firefighter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2012, 04:09 AM
  7. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 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