+ Reply to Thread
Results 1 to 36 of 36

Creating Almost Duplicate Macros Shortcut

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Creating Almost Duplicate Macros Shortcut

    I have this code below:

    Please Login or Register  to view this content.
    I basically will be making 1250 copies of the above macro each with different names and each time the Range I3 and J3 will change to I4 and J4 and the called macro of Prices4Days3 will be changed to Prices4Days4 and so on. Is there an automated way of doing that or do I need to do it manually 1250 times?

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Any ideas?

  3. #3
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Can you include the macro of Prices#Days#?
    Don't forget to mark your thread as [SOLVED].

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Quote Originally Posted by thisisgerald View Post
    Can you include the macro of Prices#Days#?
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    I have one quick question.

    If your code above will be change to Prices4Days4 what will be its new code?

  6. #6
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    The worksheet will change from OTH1 to OTH2

  7. #7
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    try this one:

    Please Login or Register  to view this content.
    Last edited by thisisgerald; 10-16-2012 at 04:13 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Invalid Next x Control Variable Reference is given when I run it?
    EDIT: Just saw your edit. Will try that now.

  9. #9
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Okay. Let me know if there will be any bug.

  10. #10
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Seems to work ok. I have now tried to adapt it to the full code which I will be using and not just the snippets above. Can you let me know if the below is correct overall?

    Please Login or Register  to view this content.
    The problem at the moment is that the word "Done" appears all the way done the page when it should only appear if FindMethod4Days# is called.
    Last edited by ScabbyDog; 10-16-2012 at 04:33 AM.

  11. #11
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    I think your code will work well.
    I've made some adjustments on the part with red font. I only merged it on your code above that.

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    The problem at the moment is that the word "Done" appears all the way down the page when it should only appear if FindMethod4Days# is called. Any ideas how to fix that?

  13. #13
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Please include your code on FindMethod4Days.

  14. #14
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Please Login or Register  to view this content.
    Thanks for your help. That is all the code now so if I get it to work like I want it will save so much time! Thank you!

  15. #15
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Give this a try. I'm not sure if this is what you want to happen.

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Quote Originally Posted by ScabbyDog View Post
    The problem at the moment is that the word "Done" appears all the way down the page when it should only appear if FindMethod4Days# is called. Any ideas how to fix that?
    What do you mean of this? In your FindMethod4Days there is also a loop that I think that will do the same as the previous one. Can you attach a sample workbook?

  17. #17
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    It seems to work. But it goes on a huge loop I think?

  18. #18
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Quote Originally Posted by ScabbyDog View Post
    It seems to work. But it goes on a huge loop I think?
    Yes I think. There's a lot of for loop on the code. You could upload a workbook and an output of it so we can know what would be much better for that. Unless you need that urgent, you could use the code above.

  19. #19
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Replace your old FindMethod4Days3 with this one.

    Please Login or Register  to view this content.

  20. #20
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    That doesn't run. Says Object Required and highlights
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    That's weird. Here is the code;

    Please Login or Register  to view this content.
    Last edited by thisisgerald; 10-16-2012 at 07:25 AM.

  22. #22
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    On sheet BundesligaFixtures1213 in "I3" if the word Done is there then it will not run. I want it to run if column J row X has the number 4 in it.

  23. #23
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Please see Post#21.

    Condition already applied.

  24. #24
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Doesn't work. When I change the J column to 4 then it doesnt copy over the figures.

  25. #25
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Quote Originally Posted by ScabbyDog View Post
    Doesn't work. When I change the J column to 4 then it doesnt copy over the figures.
    Do you want it to happen at worksheet_change?
    Because I have run your code and it seems nothing wrong in it.
    My understanding is, even there is no word "Done" in column I and column J has a value 4, the macro will run.
    Is my understanding right or not?

  26. #26
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    I will run the macro manually for now. I know how to make it happen at worksheet change when I need to.

    If Column I has Done then the macro will not run on that row.

    If Column J has value 4 and Column I has nothing then the macro will run when I run it manually. At the moment if Done is in I3 the macro will not run anywhere else even if there are no more Dones.

  27. #27
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Is the text with red font doesn't fit the condition?

    Please Login or Register  to view this content.

  28. #28
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    The code in Red is Correct. If .Range("J" & x) = 4 Then Call Prices4Days3(x). That is what I want. BUT what I am saying is that when for example J20 changes to value 4 and I run the macro nothing will happen because I3 value will be Done.

    If I3 is Done then nothing else will run even if J4 value is 4.

  29. #29
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    again. kinda weird. From the highlighted text the macro will not run anymore even there is a value of 4 in J4.

    Please Login or Register  to view this content.

  30. #30
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Quote Originally Posted by ScabbyDog View Post
    The code in Red is Correct. If .Range("J" & x) = 4 Then Call Prices4Days3(x). That is what I want. BUT what I am saying is that when for example J20 changes to value 4 and I run the macro nothing will happen because I3 value will be Done.

    If I3 is Done then nothing else will run even if J4 value is 4.
    Do you want that if you have already filled up the I3 with "Done" and J3 with 4 it will stop the macro?

  31. #31
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Yes that is right. I don't think you are understanding me though. If I3 = Done then macro will NOT run regardless of what is in J3.
    If I3 = Done and I4 is empty and J4 = 4 then the macro will NOT run when it should run in this example.

  32. #32
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Not sure if this is it. Getting hungry.

    Please Login or Register  to view this content.

  33. #33
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    Hopefully this would do.

    Please Login or Register  to view this content.
    Last edited by thisisgerald; 10-16-2012 at 08:04 AM.

  34. #34
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Please Login or Register  to view this content.
    What is the code for going to the next row though?

  35. #35
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Creating Almost Duplicate Macros Shortcut

    let me edit this:

    Please Login or Register  to view this content.

  36. #36
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Creating Almost Duplicate Macros Shortcut

    Okay. It now works perfectly. There is only one issue. If J3 = 4 then everything works perfectly. But if J3 changes to 3 (which will happen tomorrow) then no other figures will get copied over even if Jx = 4. But if I change J3 manually to the figure 4 then everything works again.

    A potential fix would be to have maybe another macro that will recognise if a cell has the value 4 and if it detects the value 4 then it will change the cell to a number which isn't affected my any formulas/macros??

    I found a fix by deleting the Exit Sub code after Else.
    Last edited by ScabbyDog; 10-16-2012 at 12:31 PM.

+ 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