# Formula stop when seeing a blank cell

1. ## Formula stop when seeing a blank cell

Hello,

Hi have a formula:

``Please Login or Register  to view this content.``
What I am trying to do get this formula to calculate and total the year that it sees. But, when the formula hits a blank cell I need it to stop. I thought I had it here but no luck. Anyone have an idea of what I'm doing wrong??

Thank you all in advance.

2. ## Re: Formula stop when seeing a blank cell

Try this array formula

=SUM(--(C8:INDEX(C8:C3322,MIN(IF(C8:C3322="",ROW(C8:C3322)-MIN(ROW(C8:C3322)))))=2006))

This is an array formula.
This means that you use Ctrl-Shift-Enter to commit the formula, not just Enter (array Enter it). Excel will put curly brackets around the formula in the formula bar, you don#t do this.
If you need to change the formula at any time, you must array Enter it again.

3. ## Re: Formula stop when seeing a blank cell

Hey Bob,

Thanks for your help!

I do not unserstand the formula at all. I am somewhat of a begginer. I did copy and past it though and all I get is #VALUE! as my result. Am I not doing something right?

4. ## Re: Formula stop when seeing a blank cell

This is the original formula that I have that works great.

``Please Login or Register  to view this content.``
The problem is, is when I insert a couple of rows like I need to do, it still calculates and totals the whole column.

Instead I would rather it stop on a blank row or cell.

5. ## Re: Formula stop when seeing a blank cell

You could try this:
In some hidden cell, say Z1 : ="C8:C"&If(IsError(Match(0,C8:C3702,0)),3702,Match(0,C8:C3702,0))
then your formula could be
=SUMPRODUCT(--(YEAR(Indirect(\$Z\$1))=2006))

[/SIZE]

6. ## Re: Formula stop when seeing a blank cell

Originally Posted by whatsmyname
Hey Bob,

Thanks for your help!

I do not unserstand the formula at all. I am somewhat of a begginer. I did copy and past it though and all I get is #VALUE! as my result. Am I not doing something right?
Did you array-enter it?

7. ## Re: Formula stop when seeing a blank cell

Originally Posted by Bob Phillips
Did you array-enter it?
Yes I did.

8. ## Re: Formula stop when seeing a blank cell

Originally Posted by foxguy
You could try this:
In some hidden cell, say Z1 : ="C8:C"&If(IsError(Match(0,C8:C3702,0)),3702,Match(0,C8:C3702,0))
then your formula could be
=SUMPRODUCT(--(YEAR(Indirect(\$Z\$1))=2006))

[/SIZE]
I do not know if I was doing something wrong but this did not work either.

9. ## Re: Formula stop when seeing a blank cell

Hi whatsmyname;
I did not test my solution.
I just assumed that an empty cell would be found with Match(0,.....). I was wrong. If you put a zero in the cell then Match(0,....) will find it, but I'm guessing you don't want to do that.

I'm trying to find a formula right now that will find the empty cell. A macro can easily find it, so if you wanted to have a macro automatically find it for you when you insert a row, I could easily write that. The macro could put a 0 in the cell then the Match(0,.....) would find it.

Let me know if you would like a macro. Otherwise I'll keep trying to find a formula that works.

10. ## Re: Formula stop when seeing a blank cell

Hi whatsmyname;

I just thought of a way to make it real easy for you.
If you put this into the sheet's module (right mouse click the sheet's tab and select "View Code")
``Please Login or Register  to view this content.``
It will always put the correct address into Z1 with one exception, if Row 9 is empty. If this is a possibility, then the macro can be changed to accommodate it
Then this formula should work.
=SUMPRODUCT(--(YEAR(Indirect(\$Z\$1))=2006))
I don't work with SUMPRODUCT, so I'm not possitive, but if it worked before, then it should work using Indirect().

11. ## Re: Formula stop when seeing a blank cell

Hi foxguy,

Thank you for your help. I greatly appreciate it. I'm not sure if I did it right, but I did copy and paste the macro directly into the workbook VBA code. Then I took your formula and pasted it where I wish my result to be. It still did not work though. I could be doing something wrong though.

If you'd like I could attach a sample workbook that way you could see what I am doing wrong??

Let me know if you think that will help.

Thank you so much for your help.

12. ## Re: Formula stop when seeing a blank cell

I went ahead and attached a workbook sample.

Once you open it, Click on the DatatoCopy tab and copy the data that is in there.

Then click on the Current Project tab and click on cell A8 and paste the data in there.

Then on the Toolbar at the top you'll see a smiley face button, click on that. It will give you an error. I have a bug and am not sure how to fix that so just click end now.

Then you'll see that I have an accumalation of dates. That all is working good. But, you'll notice that everything is seperated by duplicate locations.

I only want to total the dates by those individual locations. Meaning, that if I have a group of four and 2 of the dates are 2006 and 2 are 2010. Then I should only show 2 in the 2006 section and 2 in the 2010 section.

I hope I explained that well enough. I am very new to writing VBA, so if you see alot of mess and stuff, please understand. This is just a sample workbook as well, so I am also using this workbook to test and learn. That way I don't make a mess out of my final result.

Thank you for your help. I expertiece is greatly appreciated,

13. ## Re: Formula stop when seeing a blank cell

Hi whatsmyname;

I'm looking at your workbook now. I don't see a smiley face in a toolbar, and I don't see anywhere in your code where you added a menu selection. What macro is the smiley face supposed to run?

Also, I see that you put my macro in the wrong module. You put it into "ThisWorkbook". It should go in the Sheet module of the sheet you want to SUMPRODUCT on.
If you want it on every sheet then you can leave it in ThisWorkbook, but it should then be:
``Please Login or Register  to view this content.``

14. ## Re: Formula stop when seeing a blank cell

Hi whatsmyname;

I have attached a workbook.
On sheet "Current Project" I found your SUMPRODUCT formula in A7. I put my macro in the correct place and changed it so that it puts my formula into A4. I also changed the formula in A7 to use it.

Now you can test it by inserting a row anywhere in the data, and you should see A7 adjust accordingly.

I did not look at anything else in the sheets or macros, only the SUMPRODUCT formula in A7. This was the subject of your original message. If you like the solution, then mark the thread "Solved" and rate the answer if you liked it.

If you have more problems or questions, please start another thread.

15. ## Re: Formula stop when seeing a blank cell

Originally Posted by foxguy
Hi whatsmyname;

I have attached a workbook.
On sheet "Current Project" I found your SUMPRODUCT formula in A7. I put my macro in the correct place and changed it so that it puts my formula into A4. I also changed the formula in A7 to use it.

Now you can test it by inserting a row anywhere in the data, and you should see A7 adjust accordingly.

I did not look at anything else in the sheets or macros, only the SUMPRODUCT formula in A7. This was the subject of your original message. If you like the solution, then mark the thread "Solved" and rate the answer if you liked it.

If you have more problems or questions, please start another thread.
This worked. I thank you for your help. It still did not work like I needed it too though. The reason for that though is because I didn't think about telling you specifically which Macro to run and I jsut thought that the smiley face would be on yours. That was my fault, sorry. I'll re-attach your workbook and before you insert any rows select all of the data and then run the "seperate" macro. Then you should see exactly what I am trying to do. You solution worked very well and I tried to tweak the formula just a little bit more to get it to do what I needed it to do. But, because of my ignorance I didn't succeed. If you could look at this one more time for me I please, I would greatly appreciate it.

Thank you!!

16. ## Re: Formula stop when seeing a blank cell

Hi whatsmyname;

I'm attaching the file with Seperate() improved. You should see it run much faster, and it will appear to all happen at once, not one Insert at a time. When you run it, you will see a spinning circle while it's running, but you won't see the sheet changing at each Insert.

1) I put my formula in column "L" (the formula in L5 is a dummy as as placeholder)
2) I changed the formulas in A5:E5
3) Seperate will put my formula in column "L" for each set of inserted rows. You will see it when you run Seperate.
4) I put a lot of notes in Seperate to help you improve your programming skills.
5) When you copy Seperate into your real workbook, make sure that the addresses are correct in the section between the '******************
6) You do not need to select all the data on Current Project. I put code into Seperate so you can run it from anywhere in the workbook.

This was an interesting effort. I had never split data up like that and tried to sumproduct on the different sections.

17. ## Re: Formula stop when seeing a blank cell

Thank you so much Foxguy!!!

It works beautifully! I was beginning to think that I was asking for something that wasn't possible. I really appreciate all your help and time. I somewhat understand what you did to the seperate code. I think you were making my seperate into ranges themselves. But, alot of it still looked like a different language to me, LOL. I really appreciate all your notes and insight. I can only hope that someday my knowledge will be as vast as yours. You are truely skilled. I'm self teaching myself, so guidance like this is really really helpful. I do not understand the function methods at all though, LOL. I also need to have the prices automatically totaled, but I am going to take what I have learned and try to solve that myself. If I have trouble, I'll definately be posting another thread, LOL. Once again, thank you so much for you time and help, you are a great teacher.

Thank you!!!!

18. ## Re: Formula stop when seeing a blank cell

You're welcome.

I'd appreciate you rating my answer, by clicking the blue scales next to the message # of the answer you liked.

19. ## Re: Formula stop when seeing a blank cell

Originally Posted by whatsmyname
Hey Bob,

Thanks for your help!

I do not unserstand the formula at all. I am somewhat of a begginer. I did copy and past it though and all I get is #VALUE! as my result. Am I not doing something right?
Did you array-enter it as I explained?

20. ## Re: Formula stop when seeing a blank cell

Yes I did. And it put the squiqqley brackets around the formula and it still gave me that #VALUE! error.

21. ## Re: Formula stop when seeing a blank cell

Yes sir foxguy. Already taken care of!

22. ## Re: Formula stop when seeing a blank cell

Hey foxguy,

I am trying to do some more with this code. I am trying to get it to automatically sum the values in a certain column in the arrays. As well as trying to look at the last row of each array and count the specific values in a certain cell of a certain column for each arroay. I am trying to figure out how to do this manipulating your code but so far am not having any luck. Is this possible or do I need to right a whole new code?

23. ## Re: Formula stop when seeing a blank cell

Foxguy,

Is there a way that I can look at the last row of the set uf duplicates, and look in a certain column to see if the value contains a certain letter and if it does count it?

I think that your seperate code is the way to do this but I might be wrong.

Your help is appreciated!

24. ## Re: Formula stop when seeing a blank cell

Sorry, I can't figure out what you're asking.

Either post another workbook, or go back to the one I posted, and tell me what you're trying to do. What cells are you looking in and for what, and where would you want results put?

25. ## Re: Formula stop when seeing a blank cell

What I am trying do is, after the each set of duplicates is set, look in a certain cell on the last row of each set of duplicates and see if that cell's value contains the letter "V" anywhere in it's value and count it. As far as where to put it, it doesn't matter to much, I just need a cell that accumulates if the conditions is true.

Also, in that set of duplicates, there is another column, that contains prices, and I just need the formula to autosum those prices and put the total in the cell directly beneath the set of duplicates directly below the prices.

I hope that made sense. I'm on my cellphone typing this. Also, thank you so much for your help in correcting me in my code practices. I was in such a rush to just get something done, and the Book I am reading is really stressing that good clean organization is probably the most important thing in writing code.

Once again I can't thank you enough!

26. ## Re: Formula stop when seeing a blank cell

Sorry, this took so long.

I believe it would be easier to write another macro to go back in and sum the column and look for the "V"s.

This should get you started. Be sure and give it the correct columns in the section between the '***********
``Please Login or Register  to view this content.``

27. ## Re: Formula stop when seeing a blank cell

Originally Posted by foxguy
Sorry, this took so long.

I believe it would be easier to write another macro to go back in and sum the column and look for the "V"s.

This should get you started. Be sure and give it the correct columns in the section between the '***********
``Please Login or Register  to view this content.``
Hey Foxguy,

Not a problem at all. You're helping me and I greatly apprciate it.

Where do I put this code and how do I run it? Do I add it to the previous VBA that you wrote? I noticed that it is a function. Also, I noticed a message box in the code. I was curious if I could get the reslults to be displayed in a cell?

28. ## Re: Formula stop when seeing a blank cell

Originally Posted by whatsmyname
Hey Foxguy,

Not a problem at all. You're helping me and I greatly apprciate it.

Where do I put this code and how do I run it? Do I add it to the previous VBA that you wrote? I noticed that it is a function. Also, I noticed a message box in the code. I was curious if I could get the reslults to be displayed in a cell?
Sorry about the function. Just change it

``Please Login or Register  to view this content.``
be sure and delete the "As Boolean".
My error trapping is dependent on it being a Function. It works exactly the same as a Sub. The main difference as far as you are concerned is that it doesn't show up on the list of macros to run.

Put it in any Standard Module, probably the same module where you have "Separate".

I put the message box in just to show you that it works. It's up to you to put the value where you want it, (and delete the msgbox).

##### Users Browsing this Thread

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

#### 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