+ Reply to Thread
Results 1 to 9 of 9

Counting years in Cells

  1. #1
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Counting years in Cells

    Hello All,

    I am trying to have a cell look at a range of cells and count how many contain a certain year ex. 2006. Then I would like that cell to display the count ex. 3. If I need to attach a workbook for anyone please let me know. I would prefer to do this as a function in the cell itself but if I have to do a macro for it that will be okay too. Actually a macro might be better because I might have that range as an array.

    Hope I explained this well enough.

    I've tried to search for this but I am just not finding exactly what I need. And my knowledge on VBA is still somewhat elementary. Sorry.

    Any help is greatly appreciated.

    Thank you.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Counting years in Cells

    have you tried COUNTIF?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Counting years in Cells

    Forgive me for my ignorance, but how would I do that? I'll search to see if I can find an answer, I am pretty ignorant when it comes to formulas. And I left my EXCEL 2003 For Dummies at the house. Lol.

    I will deffinitly look for that though. Thank you for your help.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting years in Cells

    It would depend what exactly is in the cells you are counting... a date or just a year.


    If it is a date, you will need something more like:

    =Sumproduct(--(Year(A1:A10)=2006)) where A1:A10 contain the dates

    if it is just years in the cells, then

    =Countif(A1:A10,2006)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  5. #5
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Counting years in Cells

    Wow, Thank you! My mind is boggled from reading all the information on here. The =Sumproduct is what I need. It worked great!!!!!

    But, I it's totalling everything that I have in my range. I would like it to only total until it hits a blank cell. I'm looking on how to do that but I'm not having any luck finding what I need. Although I'm sure I just haven't looked in the right place. If you could give me an idea or at least point me in the right direction that would be great!!!

    Thank you very much for your help.

  6. #6
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Counting years in Cells

    You know actually I was thinking.....I think I am doing things in the wrong way. If you wouldn't mind, let me explain what I am looking for my end result is.

    1) I am copying a large amount of data into my worksheet. Column E of all this data contains multiple duplicates.

    2) I have a VBA that automatically resizes and formats all the information that I copied.

    3) Then the VBA formula automatically inserts 3 blank rows inbetween all of the duplicates in column E.

    4) (I still need to figure this part out) I have 2 rows that are constantly part of the worksheet that I would like to insert (or copy too) 2 of all those blank rows just above the first row of duplicates. Inside of those 2 rows are the =Sumproduct Year formulas. What I would like is, when I run my VBA to seperate my duplicates that it would automatically insert those 2 rows just above every set of duplicate and total all of the dates in just that set of duplicates.

    6) (I still need to figure this part out) Then in all that data there are also prices that I would like to total just in that set of duplicate data. I know how to total the prices but I don't know how to make it total and stop when it hits a blank cell.

    I have an EXCEL 2003 for Dummies that I am reading as well as VBA for dummies that I am reading, because I want to educate myself. But, I think I am trying to do things that are to advanced for knowledge right now. Any help that you could offer is greatly appreciated!! If you would like I could attach a copy of my document??

    Thank you.

    Your help this far is much appreciated.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Counting years in Cells

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  8. #8
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Counting years in Cells

    Okay,

    I have attached a workbook. I have alot going on here so I'll start off kind of simple and please ask questions as needed.


    First- After you open the workbook, it'll open up on the "DatatoCopy" tab. Copy the selected data.


    Second- Click on the "Current Project" tab. Right click on cell A7 and paste the data.


    Third- Click on the Smiley face Icon button in the toolbar at the top. And that's what I have accomplished so far. (With yours and everyones help, which is much appreciated, thank you.)


    Fourth- Click on the "Result" tab. This is what I want my end result to be. Somebody else did this on their own manually. What I am trying to do is automate this as much as possible for them.

    I think that I will be able to do that. My knowledge is just not that advanced yet. I am trying to self educate just not as quickly as I'd like.



    The items I have left to accomplish is:

    1) Have rows 5 & 6 on the "Current Project" tab be copied and pasted just above every set of data that was seperated in the "Current Project" tab. Then have the formulas that are in the cells in row 6 stop when they see a blank cell.


    2) Have the prices that are in column H in the "Current Project" tab autosum and stop when they see a blank cell. Hope that made sence.


    3) I know how to get the formula for the run times that are in column A in the "Current Project" tab to work. I'm just not sure how to get them to work automatically and use todays date when they see a blank cell. I can do it all manually, I'm just not sure how to do it automatically.


    4) Add the outlines or "borders" around all the cells that have data in them besides the cells that contain the data in Rows 5 & 6.


    I'm sorry I need so much help. As I said before I am trying to self educate just not fast enough. I was reading something about "arrays". I wonder if that would be better to do. Still not up to speed on how to do that though.

    Any help is greatly appreciated and even if you could point me in the right direction that would be a tremendous help. Thank you all in advance and have a wonderful 4th of July.

    Thank you.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Counting years in Cells

    Just checking to see if anyone could help me with this one.

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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