+ Reply to Thread
Results 1 to 21 of 21

Macro for Filling the empty cells based on current date.

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

    Macro for Filling the empty cells based on current date.

    Dear Friends,

    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.
    Last edited by aneshdas; 01-10-2014 at 03:14 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Macro for Filling the empty cells based on current date.

    why even bother to put in anything for p? you could probably work out a formula that will count blanks, just as easily as it could count p's
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: Macro for Filling the empty cells based on current date.

    Sir, I think ISBLANK will be Ok. But I need to check whether there is any value in respective "B" cell before putting the "P". Also due some other reasons I cannot initiate any excel formulas in this main sheet. So requesting you to kindly provide me a macro for the same. thanks in advance sir.

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

    Re: Macro for Filling the empty cells based on current date.

    Friends,

    Can I anybody help me Please? I am sitting in front of the system since in the morning for getting an answer for this query. Kindly help me by providing a macro for the same.

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

    Re: Macro for Filling the empty cells based on current date.

    Friends,

    I have just configured a macro. But this one is not searching whether there is any value in respective "B" cell or not. Kindly add that for me. Means, Now this macro will select the current date's 2:500 cells and replace the empty cells with P. I need the Macro to search the respective "B" cell also and if there is NO value in the respective B cell, current date columns Selected Cell should be empty. Kindly help..

    Please Login or Register  to view this content.

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

    Re: Macro for Filling the empty cells based on current date.

    Dear Friends, Why no body is helping me. Kindly provide me a solution Please

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

    Re: Macro for Filling the empty cells based on current date.

    Quote Originally Posted by FDibbins View Post
    why even bother to put in anything for p? you could probably work out a formula that will count blanks, just as easily as it could count p's
    Sir, I think ISBLANK will be Ok. But I need to check whether there is any value in respective "B" cell before putting the "P". Also due some other reasons I cannot initiate any excel formulas in this main sheet. So requesting you to kindly provide me a macro for the same. thanks in advance sir.

  8. #8
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Macro for Filling the empty cells based on current date.

    aneshdas, try this. Also, you might want to think about not hiding rows that are a date in the future.

    Please Login or Register  to view this content.
    Greg
    Just a guy trying to make work stuff easier.

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

    Re: Macro for Filling the empty cells based on current date.

    Quote Originally Posted by gsnidow View Post
    aneshdas, try this. Also, you might want to think about not hiding rows that are a date in the future.

    Please Login or Register  to view this content.
    Greg


    Sir, Thanks a lot for your reply. Two Errors are there in your macro sir.
    1. First this macro is filling "P" only in the cells which's respective "B" cell is empty. Iwant it in vice versa. That is if No value in B no value should be in the respective date's cell.
    2. Also this macro is changing all the Cells in the dates column in to "P". So this will clear the values which I already entered. More clearly, I am already entered the "A", "L", etc in some of the cells in the current date column. I do not want to change the values on those cells. So, Simply what the macro I required has to do is, Replace the EMPTY cell's in the Current date's column with "P" ONLY IF there is any value in their respective "B" Cell....Sir, hope you get my point and will help me accordingly.
    Last edited by aneshdas; 01-10-2014 at 07:12 AM.

  10. #10
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Macro for Filling the empty cells based on current date.

    Ok, try this...
    Please Login or Register  to view this content.

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

    Re: Macro for Filling the empty cells based on current date.

    Quote Originally Posted by gsnidow View Post
    Ok, try this...
    Please Login or Register  to view this content.


    Heyhey :-)..... Thanks a lot sir.it is working..... Hurray... :-)
    Last edited by aneshdas; 01-10-2014 at 08:00 AM.

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

    Re: Macro for Filling the empty cells based on current date.

    Sir, But it is taking tooooooooooooooo much time to process. Can you advice how to shorten this process? Since I have a lot of employees this process is giving me headache.

    Sir, I have already a macro for only displaying the column which having the current date. Is there anyway to calculate with that sheet only......Even though we applied the Screen updating= false, the process is going on going on.................. please advice me how to sort this issue.

    With in this macro I hope you got the logic of what I need.
    Last edited by aneshdas; 01-10-2014 at 08:05 AM.

  13. #13
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Macro for Filling the empty cells based on current date.

    Is there some other code running when you file this macro? I mean, it is only hiding a few columns, then iterating through a 500 cell range on only 1 column. This code alone should not be taking so long. Do you have formulas in lots of cells? Could you attach the workbook?

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

    Re: Macro for Filling the empty cells based on current date.

    Sir, I AM USING NO EXCEL FORMULAS IN MY WORK SHEET EXCEPT SOME MACROS. I am using a bunch of macros in this spreadsheet. But nothing is connected with this macro. And the macro which I posted was running in no time. Also the macro which you provided before the last one was also running without taking any time. Only the macro which you provided was taking much time. More over that apart from the column which contains current date has already hided while opening the workbook itself using another macro. So no need to hide it again. And no other macro's are running at the same time when the macro provided by you runs. So sir, kindly check it and please provide me a simple form of this which can run in no time. Thanks in advance sir. Also the work contains a lot of datas and I am trying to make a copy of the same for your ready reference. Kindly work on this sir.
    Last edited by aneshdas; 01-10-2014 at 11:19 AM.

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

    Re: Macro for Filling the empty cells based on current date.

    Sir, is this "Len" process taking time? Kindly check and advice me sir.

  16. #16
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Macro for Filling the empty cells based on current date.

    You can do it without the Len() validation, but it should not make much of a difference. I made a mock up of what I think your worksheet looks like, even filling names in column b for 1000 rows. The macro runs in mere fractions of a second. If it is taking a long time on your workbook, please let us see what you are working with by attaching a de-sensitised version of it.
    Please Login or Register  to view this content.
    Greg

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

    Re: Macro for Filling the empty cells based on current date.

    OK sir. I will post the sample work sheet tomorrow as soon as I reach my office. Hope you will be online and will help me tomorrow. Thanks sir.

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

    Re: Macro for Filling the empty cells based on current date.

    Sir,

    When I reduced the number employees to 4, it is working fastly. but when it is nearly 100 employees it is taking time. Can you just simplify the process in another way? The same process I need to be in a fast way. Kindly do that for me sir. Since there is lot of of data associated with the xlsm file I am using, it is difficult for me to post the same as sample. But anyway I am trying for it. meantime just try for me a fast process sir.

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

    Re: Macro for Filling the empty cells based on current date.

    Sir,
    I think the following portion is taking much time, can you suggest an alternative code for this which can speedup the process sir?
    Please Login or Register  to view this content.

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

    Re: Macro for Filling the empty cells based on current date.

    sir,

    Please see the attached file. I am already posted a new thread regarding this.
    Attached Files Attached Files

  21. #21
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Macro for Filling the empty cells based on current date.

    aneshdas, on my machine, Windows 7 32bit i5, 4G ram, it literally takes fractions of a second to run. I'm kind of stumped as to why it would be taking so long on your machine.

    Greg

+ 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. MACRO to empty a range of cells based on whether specified cell is empty
    By TBJV in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 10:35 PM
  2. Macro for Filling First Empty Row Based on row above value
    By miners in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-19-2009, 09:51 PM
  3. Filling cells with 3 different colors based on date in cell and todays date
    By chinookcrew in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-23-2009, 07:36 AM
  4. Filling in a cell based on another cells date criteria
    By cmatera in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-21-2008, 10:11 AM
  5. Run macro based on current date
    By yaju1120 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-05-2007, 10:30 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