+ Reply to Thread
Results 1 to 20 of 20

How to simplify this macro

  1. #1
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    How to simplify this macro

    Friends,
    Can you help me to simplify this code.
    this one taking much time to process. The current date will be in the 7th row. and there is another macro is already there to hide columns except today date's one. Also this code has got from a post of mine on this forum only. Hope I am not violating the forum rules. Friends, Kindly help me with this. :-)

    Please Login or Register  to view this content.
    Last edited by aneshdas; 01-13-2014 at 03:49 AM.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: How to simplify this macro

    Hi aneshdas, first, it's really not very nice to say things like "PLEASE HELP ASAP", it sounds even worse when in caps. People here give help out of good will, not obliged to. Next, it would help if you gave same info on what your macro does, you are familiar with what you are doing, but others are not.

    And how much time do you mean when you say "taking much time to process"? It seems you are only looping through about 30 columns of 500 rows, should not be taking too long.

    See if this makes any difference?
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Please Login or Register  to view this content.
    Only this area is taking much time when I checked. :-(

  4. #4
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    I am extremely sorry for that sir. Since I am in front of the system and I will get the system only for a short time, thus only i mentioned so. I will do the editing.

  5. #5
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Quote Originally Posted by millz View Post
    Hi aneshdas, first, it's really not very nice to say things like "PLEASE HELP ASAP", it sounds even worse when in caps. People here give help out of good will, not obliged to. Next, it would help if you gave same info on what your macro does, you are familiar with what you are doing, but others are not.

    And how much time do you mean when you say "taking much time to process"? It seems you are only looping through about 30 columns of 500 rows, should not be taking too long.

    See if this makes any difference?
    Please Login or Register  to view this content.
    Sir, My requirement is mentioned below. Kindly help me sir. Also the code which I have posted taking 8 second to complete the process since rest of the macros takes only fraction of a second.

    "I have a spreadsheet for entering Employee's details. On that I am entering employees daily attendance status. It is almost 600 employees and entering each and every employee is a herculean task. So What I need is, I can enter on the Absent, Casual Leave, and etc...and the remaining unmarked staffs will be PRESENT. So that If I have a command button for that, when I click that button it should automatically apply "P" on the remaining cells on that particular date's column. More clearly, I have 31 columns for each days in month and on each column's 7th ROW contains that particular day's date. So the macro has to search the empty CELL's between current date's particular column and fill it with "P". The empty cells will be between 8th row to 500th row on each day's column. One more thing the macro has to check. The empty cell on each day has to fill ONLY IF that cells respective "B" cell having any value. More clear I am entering Employees name in the "B" Column from 8 th to 500th row. So, After clicking the command button, macro has to find that particular date containing column and find the empty cells between that column's 8th ROW to 500th ROW and has to fill those empty CELLS with "P" ONLY IF there is any name in the B column."

    Kindly Suggest me a macro for this.

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: How to simplify this macro

    So did you try the amended code?

  7. #7
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Yes Sir, that too is taking the same time. :-(

    Please Login or Register  to view this content.
    This was the code I used first. This was perfectly fast and takes only a fraction of second. But this Code is not checking whether there is any name in the B column or not.

  8. #8
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: How to simplify this macro

    The code should be completing in less than a second. The only reason I can think of why it would run so slowly for you is because of other formulas / conditional formatting's that involve looking at the cells' value = "0" or "P".

  9. #9
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    So how to overcome that barrier sir?

  10. #10
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Yes Sir, I am using Data Validation on the selected columns. But how come it working very fast when I used the last code which I mentioned last? Kindly provide me a solution for this sir.

  11. #11
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: How to simplify this macro

    One thing you can try is removing the data validations, before replace "0" with "P", and then add it back.

    Below is an example of how it can be done, but no guarantees it will improve on speed. Also, back up your file first and run this on a copy, lest you lose your data validations. I don't know what's in your validation list, so dummy values of List option 1 and List option 2 in this example.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Still the same speed. :-( Validation has restored.....

    The thing I don't understood is why it is not taking any time on the code I have entered first, which is not checking the status of 2 column...

  13. #13
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: How to simplify this macro

    My guess is using replace would not invoke validation checking (totally a guess).

    Worth a shot:
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    this is not working Since c.Value is not Zero. i replaced the Zero with "". but the result is the same.

  15. #15
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Sir,

    Forget about the code I provided. Can you please give me a new code based on my requirements mentioned above? Please

  16. #16
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Sir,
    Is it because the Columns except today date is already hidden. So is that why the process taking time since going through hidden column is expensive??

  17. #17
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: How to simplify this macro

    aneshdas,
    as i read the posts, your solution works but slowly, yet it still works... so 100% for the original problem is solved

    So it may be a bit slow, I suggest that instead of asking for "new code" to magically fix your "issue" that you actually experiment a bit.

    You seem to have identified the area in your code that is slow, do some research on how to achieve the same result in a quicker time

    And I have to repeat a mantra from many other posts... include a sample with your problem clearly shown as well as your expected result... a lot of us like to simply "play" until we get an answer but we "HATE" creating test data for a situation we don't understand.

    we are a self help group, not a free complete solution provider.

    play by the expected rules and you will be rewarded, make demands like "give me the new code" and you will quickly run out of help

  18. #18
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Sir,
    Here is the sample workbook.
    Attached Files Attached Files
    Last edited by aneshdas; 01-13-2014 at 07:16 AM.

  19. #19
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Friends,

    Kindly go through the attached sample file and please provide me a solution to speed up the process.

  20. #20
    Registered User
    Join Date
    12-04-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: How to simplify this macro

    Sir,
    Have you got the sample file? Hope you have seen the issue.

+ 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. [SOLVED] How to simplify Macro IF function
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-19-2013, 04:31 AM
  2. I need macro/ vba help to simplify a report
    By sjoseph in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-02-2013, 03:30 PM
  3. Simplify macro
    By iamasimpleman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2011, 07:01 AM
  4. How do I simplify this macro?
    By snooze24 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2009, 04:47 PM
  5. Simplify a macro
    By Einar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-23-2005, 05:05 AM

Tags for this Thread

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