+ Reply to Thread
Results 1 to 31 of 31

Macro not responding

  1. #1
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Macro not responding

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Hi can anyone help me with these codes. For some reason they are now taking forever to run. I am not sure it even finishes because i cancel after about 45minutes.

    Thanks

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    Are there many formulae in your file? If yes, then add this statement
    Please Login or Register  to view this content.
    after your last Dim statement in each code. And add this statement
    Please Login or Register  to view this content.
    before the End Sub.

    Also it tends to happen that the files get corrupted after repeated use. So you can copy the contents to a new file, add in all the macros and see if the problem persists.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    You are making a lot of copying, that's why it's slow. Try to copy whole columns instead of single rows one by one. Or instead of copying, just get the value.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    Also, you can empty your clipboard by doing this

    For the 1st code, replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    For the 2nd code - replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Hi Arlu

    I suspected it was corrupt because I had alot of computer issues this past week so I already tried to copy everything to a new file. Funny thing is that the macros would not run in workbooks that they previously did run in. I will try your suggestions now.

    I just want to clarify the below:

    I wanted to copy formula results from my initial sheets to the sheet that the macro makes. The two macros above are supposed to do this but I suspect I have done something incorrect here. On the one sheet when it did manage to run the macro it copied the formating for protecting the certain cells. i wanted it only to copy the formating that resulted in the red cells.

    Perhaps instead of me coping the formating from the origanal sheets I should set the formating up within the macro so that it runs it on the macro generated sheet. (I would need help with this as I would not know where to start)

    What do you think?

    Terri

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    You can try the changes i suggested. If it still gives you issues, we can re-work the formatting code part.

  7. #7
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Should i try to make all the changes at once or first post two and then post 4. I have tried to do just post one and after ten minutes it is still not complete.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    Try one code at a time. Change the entire code as per what i suggested.

  9. #9
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Hi

    I tried both and sadly they are still not working.

  10. #10
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    When I terminate it it always debugs highlighting the following:

    Range("A4:K" & lrow).Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(5, 7), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=True

  11. #11
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    @ TERRI LEE #10:
    try to exclude that line and see what happens when running the code. Maybe that's what causing the main problem.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    The code in post 10 is needed as she needed subtotals to be inserted in the file.

  13. #13
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    Quote Originally Posted by arlu1201 View Post
    The code in post 10 is needed as she needed subtotals to be inserted in the file.
    Okay, but first let's identify the problem and see what's causing the macro to be so slow. (I might have been wrong in post #3 that the copying took so long.)

    After that we can move on to find an alternative code for the slow part. At least that's the logic I'm trying to follow.

  14. #14
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    How do i fix this

  15. #15
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    The macros ran fine until we added the lines coping the formats. If I take these out it runs fine.

  16. #16
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    In that case I suggest using the old macro and add some formatting code at the end.

  17. #17
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Thats great but I am new to macros and what I have tried thus far has not worked.

  18. #18
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    If you attach a sample workbook that shows how it should look like, I can help you with it.

  19. #19
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Please Login or Register  to view this content.
    Hi this is what I have come up with. I need help with the following sections please:

    Please Login or Register  to view this content.



    Please Login or Register  to view this content.
    Here i wanted a red fill in the cell if there is no text in cells in column C ( it should exclude the subtotal and total rows)

    In actual fact all 4 conditional formatings in the macros should exclude the subtotals and totals rows.
    Attached Files Attached Files

  20. #20
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro not responding

    In that case, you can put the color formats for the rows and then do the subtotals.

  21. #21
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    What arlu said, or you can use this code:
    Please Login or Register  to view this content.
    instead of this part
    Please Login or Register  to view this content.
    I made some comments to make it clear. Note that the code is not conditional formatting, it's just simple formatting.
    Last edited by RHCPgergo; 04-07-2013 at 09:07 AM. Reason: oops, condition is <> "total", not = "total"

  22. #22
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Hi

    If I use the code from RHCPgergo where do i insert it into my code. I also needed help as per post 19 with the two corrections that needed to be made.

    Terri

  23. #23
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    It should look something like this. In the code I already made the two corrections - at least I think that's what you wanted.
    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Hi

    If I want to insert your changes in the macro to run before the subtotals etc where would I insert it?

  25. #25
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Please Login or Register  to view this content.
    What does this actually mean in laymen terms.

  26. #26
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    Quote Originally Posted by TERRI LEE View Post
    Hi

    If I want to insert your changes in the macro to run before the subtotals etc where would I insert it?
    Before this line I guess, but why do you want to do that? Doesn't it work the way you want?
    Please Login or Register  to view this content.
    About the meaning of this line:
    Please Login or Register  to view this content.
    Rng is a range variable. I use it in a loop so it always means the corresponding cell in column D. (D5, then D6, D7, etc.)
    Rng.Offset(0,1) means the cell that is one cell right from the Rng cell. (E5, E6, E7, etc.)
    Rng.Offset(0,3) means the cell that is three cells right from the Rng cell. (G5, G6, GE7, etc.)
    Rng.Offset(0,1).Value means the value of the referenced range/cell.

    So all in all it means what I have already written in the comments in the code: if value in column E is greater than zero AND value in column G is smaller or equal to zero then make the color of the cell in column G red.

    (You could write the whole thing in one line, like this, the underscore (_) means that it's one line of code.
    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    It does work fine in the driver analysis but in the other macro called truck analysis it seems to highlight the subtotals row in column C. i thi=ought if this was inserted before it runs the subtotals it would fix it.

    Thanks once again for your help.

    Terri

  28. #28
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Please Login or Register  to view this content.
    Sorry to be a pain but I'm still learning. What does this mean.

  29. #29
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    Quote Originally Posted by TERRI LEE View Post
    Please Login or Register  to view this content.
    Sorry to be a pain but I'm still learning. What does this mean.
    Rng: this is a range variable in which I store a single cell. (For example A1.)
    Rng.Text: the text value of a range/cell. (Let's say the value of the cell is "Profit Total")
    LCase(Rng.Text): makes the text lower case. (In the example "profit total")
    Right(LCase(Rng.Text), 5) : cuts down the right side of a string, 5 characters (in the example "total")

    So the line means: "if the last 5 characters (lowercase) does not equal 'total', then"

  30. #30
    Forum Contributor
    Join Date
    05-31-2012
    Location
    South africa
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: Macro not responding

    Okay thanks now I at least understand what it is saying. I will be able to make the changes for the other macros where I want to insert this info. Thanks a million.

    Regards Terri

  31. #31
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro not responding

    Glad I could help.

+ 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