+ Reply to Thread
Results 1 to 12 of 12

Improper formatting of macro code regarding selection

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Improper formatting of macro code regarding selection

    Please Login or Register  to view this content.
    I recorded a quick macro from which I pulled the above selection code from and then tried inserting it into the below code.

    Please Login or Register  to view this content.
    The code will successfully open my word document but then I will get a 'Run time error 1004' Method 'Range' of object'_Global' failed. When I click Debug it shows this line being highlighted

    Please Login or Register  to view this content.
    What is the proper formatting for this section of code?

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

    Re: Improper formatting of macro code regarding selection

    What are you actually trying to do with the Word document?

    What range are you trying to select in Excel?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Improper formatting of macro code regarding selection

    You might try:
    Please Login or Register  to view this content.
    I'm not that familiar with word.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  4. #4
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Improper formatting of macro code regarding selection

    I am trying to copy and paste a range from the Calculator sheet of my excel workbook into a word document. The range is U1:X1 and then Ctrl + Shift+ down arrow to select all the rows that have data in them. Each time this is executed there may be varying amount of rows that have data. I am referring to two youtube videos which deal with this subject in order to set up the macro.

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

    Re: Improper formatting of macro code regarding selection

    If you want to refer to that range on a worksheet named 'Calculator' you could use something like this.
    Please Login or Register  to view this content.
    You could then copy the range to Word like this.
    Please Login or Register  to view this content.
    Last edited by Norie; 09-02-2014 at 02:14 PM.

  6. #6
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Improper formatting of macro code regarding selection

    Please Login or Register  to view this content.
    Now I get a run-time error 424, object required message. When clicking debug it highlights this line.
    Please Login or Register  to view this content.

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

    Re: Improper formatting of macro code regarding selection

    What's wDoc?

  8. #8
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Improper formatting of macro code regarding selection

    http://www.youtube.com/watch?annotat...&v=yJFVTou3QIg

    It is how the code is written in this video, much of this is blindly copied so I don't understand many of the fine details.

  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: Improper formatting of macro code regarding selection

    It should be this.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Improper formatting of macro code regarding selection

    Thank you! It is working good enough to figure out the next step.

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

    Re: Improper formatting of macro code regarding selection

    Did you try downloading the workbook(s) that are mentioned in the video?

  12. #12
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2010
    Posts
    452

    Re: Improper formatting of macro code regarding selection

    Yes I did, that is where I got the overall format for this macro.

+ 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. Assigning a macro to a drop down selection that will override conditional formatting
    By Kiyachantelle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2013, 04:00 AM
  2. Help needed in macro/VBA selection and formatting
    By hassanq23 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-19-2012, 04:43 AM
  3. SaveAs/GetSaveASFilename Macro Confusion/Improper operation
    By kelwood in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2012, 01:24 PM
  4. Modifying VB Code/Macro to put selection into body of email instead of attachment.
    By excelstacy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2011, 05:34 PM
  5. VBA Macro code to clear drop-down menu selection.
    By lealea1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2007, 12:05 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