+ Reply to Thread
Results 1 to 11 of 11

macro assigned to button to enter name range in row below cursor

  1. #1
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    macro assigned to button to enter name range in row below cursor

    Hi,

    I have a named range which is actually just a single row that includes specific formula and formatting (it is called AddiitionalRow and is on Sheet2 A1:A25)

    Please can you kindly provide me with the vba that can be assigned to a button on Sheet1 that, when clicked, will insert the named range in a table on Sheet1 in the row below where the cursor is?

    Thank you

  2. #2
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    Please help!

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: macro assigned to button to enter name range in row below cursor

    The description is a bit confusing. You say the named range is a single row but A1:A25 is twenty-five rows and one column.

    At any rate, try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    That works brilliantly thank you.

    Please can you adapt the code for me so that it always enters the named range starting in columnA e.g. if my active cell is Sheet1 F5, it will enter the additional row in Sheet1 A6?

    Thank you

  5. #5
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    Hi,

    The following code is inserting my named range (which is an entire row) perfectyly when my table in 'Details' is not filtered. However, when my table in Details is filtered I get the following error "Run time error 1004 Insert method of Range class failed" - please can you show me how to resolve this?

    Please Login or Register  to view this content.
    Thank you

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: macro assigned to button to enter name range in row below cursor

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 10-19-2013 at 01:08 PM.

  7. #7
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    Thank you for your response.

    The new code does enter a row but also returns the following error at the same time: run time error 1004 - The information cannot be pasted because the copy area and the paste area are not the same size and shape.

    Any ideas?

    Thank you

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: macro assigned to button to enter name range in row below cursor

    Quote Originally Posted by penfolda View Post
    Thank you for your response.

    The new code does enter a row but also returns the following error at the same time: run time error 1004 - The information cannot be pasted because the copy area and the paste area are not the same size and shape.

    Any ideas?

    Thank you
    What's the address of AdditionalRow? You said it was only one row.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    Hi,

    It is just one row. It is row2 on Sheet 'AdditionalRow'.

    What is the code for that you posted?

    Thank you

  10. #10
    Registered User
    Join Date
    09-21-2013
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: macro assigned to button to enter name range in row below cursor

    Hi,

    Please find my workbook attached.

    If you click the add row button, you will get the error described.

    Thank you for your help.
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: macro assigned to button to enter name range in row below cursor

    You have hidden columns F:N. That causes the error when you paste an entire row.

    This will unhide the columns, paste the row, rehide the columns.

    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 06-17-2010, 06:57 AM
  2. Hide Button After Assigned Macro Has Run
    By Tyler_Durden in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2009, 02:01 PM
  3. Change macro name assigned to a button
    By Tortus in forum Excel General
    Replies: 1
    Last Post: 05-25-2008, 05:22 AM
  4. Macro assigned to a button
    By rmanthorpe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2006, 07:22 AM
  5. [SOLVED] How do I know what macro is assigned to a button?
    By Denise in NC in forum Excel General
    Replies: 3
    Last Post: 04-03-2006, 09:35 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