+ Reply to Thread
Results 1 to 13 of 13

Why does macro work in one book and not another?

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Why does macro work in one book and not another?

    I have assistance in another thread writing a vba
    HTML Code: 
    . That vba was written and crafted to do exactly as requested, but i've run into an issue with running that vba on other worksheets. I have two sheets attached. The one titeld "does work" is what I was given from the aforementioned thread. The Does not work is what will be hereafter as that is what out program will generate.

    I can't figure out what the differences are between the two workbooks.

    I run my VBAs from PERSONAL.XLSB. So it is the same vba running each time.

    Sorry if the Admins believe this is a continuation of the other thread, but that thread was answered and this is a separate issue and one that isn't tied to the previous specific vba.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Why does macro work in one book and not another?

    no code in book that does not work


    Cheers
    Leo

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Why does macro work in one book and not another?

    Does this work?
    Attached Files Attached Files
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Why does macro work in one book and not another?

    Yes. Tested in Excel 2013 64bit.

  5. #5
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    Sorry, wasn't sure about using the previous's post macro and blend the posts, since I was pretty sure this was a workbook (or i'm a dummy) issue.


    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    Edit* sorry. Tried again. seems to have worked. I am going to try few other sheets, but what did you do different?

    Didn't work in another workbook. What are you doing to the book when you add your macro and resend?

    The only difference I can see in the macro you just sent was you change it to ActiveSheet. I am not questioning your macro. I know it works. So that isn't the issue.
    Last edited by taylorsm; 02-27-2017 at 11:11 AM.

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Why does macro work in one book and not another?

    Okay, didn't know that you was placing this inside your personal macros. Try this

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    That seems to be working. So what is it? I see you have Private Function now, With .Cells(i, "H") has changed too. Either way, why would your macro work in your book but not others?

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Why does macro work in one book and not another?

    Excel doesn't see UDF in your personal macros workbook, unless they're an add-in I believe. So I just looped thru the range passing the value to the function instead of a in cell formula.

  10. #10
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    I gotcha. OK. That makes sense. I really appreciate it. I sent it over and tried it off a brand new report and it works great.


    One last question if I may that was brought up when I sent it over. Is there a way to add in WORKDAY into the today()-f2? or whatever would account for holidays and weekends?

  11. #11
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Why does macro work in one book and not another?

    So you are meaning do not count the weekends or holidays in the days or last payment column?

  12. #12
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    Correct! In the days since last payment.

  13. #13
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Why does macro work in one book and not another?

    Something like?

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    if I want to avoid counting the current day.
    Last edited by taylorsm; 02-27-2017 at 12:19 PM.

+ 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. Current work book .xlsm convert to xlsx work book then mail
    By Vcare in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-26-2016, 09:47 AM
  2. VBA Code for populating cells from one Work Book A to another Work Book with condition
    By ray.kanata in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 06-22-2015, 03:46 PM
  3. [SOLVED] Macro to generate new work book
    By kriahnadas.oo7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 08:47 AM
  4. Replies: 2
    Last Post: 06-20-2012, 05:10 AM
  5. Replies: 0
    Last Post: 02-14-2011, 03:07 AM
  6. how to get a macro to work with any work book name
    By Wade LEES in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-24-2009, 06:18 AM
  7. Replies: 1
    Last Post: 07-04-2005, 05:05 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