+ Reply to Thread
Results 1 to 7 of 7

Macro to copy formula to end of data based in another sheet

  1. #1
    Registered User
    Join Date
    08-31-2012
    Location
    Yorkshire
    MS-Off Ver
    Excel 2010
    Posts
    7

    Macro to copy formula to end of data based in another sheet

    Hi,
    so I'm new to macros but I've been searching lots of sites but cannot find the answer to my question.

    I am trying to get a formula to copy down a column in one sheet but only as far as there is data in another sheet in the same workbook. I'd be using VBA (I think) and I've found macros to get it to copy a formula down to the bottom of data within the same sheet but I cannot work out how to get it to run from another sheet. Below may have also been messed up in my failed attempt :/

    Please Login or Register  to view this content.
    That Is the code I've managed to find and the values for columns, cells and sheets are correct for where it needs to come from. The problem I am having is that I get a "Compile error. Expected: end of data" on the range line.

    Hope someone can help, everything I know about macros is self taught very recently. Even a better code that actually works would be welcomed with open arms

    Thanks
    Waz

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to copy formula to end of data based in another sheet

    Maybe:

    Please Login or Register  to view this content.

    Is all that code supposed to run on the CARD sheet? If so:

    Please Login or Register  to view this content.

    By the way, that A6 and D6 look wrong to me in that formula. I would expect the formula to be anchored on row2.
    Last edited by JBeaucaire; 08-31-2012 at 01:11 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-31-2012
    Location
    Yorkshire
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro to copy formula to end of data based in another sheet

    No It will be running on a sheet named "DUPLICATE CHECK" but will be taking values from the sheet named "CARD" from column D if column a matches the criteria of "cd" (its a reference code for us).

  4. #4
    Registered User
    Join Date
    08-31-2012
    Location
    Yorkshire
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro to copy formula to end of data based in another sheet

    I tried the following and got a runtime error 13 type mismatch and when i ran the debug It showed the red line as the problem. Being new to this I am not sure how to fix it.

    Please Login or Register  to view this content.
    Any help at all is appreciated

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to copy formula to end of data based in another sheet

    based on what you said in post #3

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-31-2012
    Location
    Yorkshire
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Macro to copy formula to end of data based in another sheet

    Thanks a bunch it works perfectly I may not fully understand it but it's definitely helped me a lot!

    Waz

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro to copy formula to end of data based in another sheet

    @ Wazations

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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