Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2014, 07:25 PM
Natalee Natalee is offline Help with LEN and Substitute function Windows 8 Help with LEN and Substitute function Office 2013
Novice
Help with LEN and Substitute function
 
Join Date: Nov 2014
Posts: 6
Natalee is on a distinguished road
Default Help with LEN and Substitute function

Hi,



I am using the LEN and Substitute function to count numbers in a single cell. As an example, I have a cell that contains the numbers 5,15,25,30 and this would give me a count of 4. I am okay with this calculation.

Where I have a problem is omitting the blank cells or cells that contain 0. The function always gives me a 1 even when I added to ignore zeros. This is my formula:

=LEN(SUBSTITUTE(F20&",",",0",""))-LEN(SUBSTITUTE(SUBSTITUTE(F20&",",",0",""),",","") )

Can someone please help me figure out how to get this right?

Thanks,
Nat
Reply With Quote
  #2  
Old 11-07-2014, 07:59 PM
whatsup whatsup is offline Help with LEN and Substitute function Windows 7 64bit Help with LEN and Substitute function Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Hi Nat

I rather would go with this:
=IF(OR(F20="",F20=0,F20="0"),0,LEN(F20&",")-LEN(SUBSTITUTE(F20,",","")))

Cheers
Reply With Quote
  #3  
Old 11-07-2014, 08:10 PM
Natalee Natalee is offline Help with LEN and Substitute function Windows 8 Help with LEN and Substitute function Office 2013
Novice
Help with LEN and Substitute function
 
Join Date: Nov 2014
Posts: 6
Natalee is on a distinguished road
Default

Hi whatsup,

This actually worked for the 0! Yeah! It still gives me a 1 for a blank cell, but I can get around that. The 0 was my main issue!

Thanks a bunch!! Much appreciated!

Nat
Reply With Quote
  #4  
Old 11-07-2014, 08:15 PM
Natalee Natalee is offline Help with LEN and Substitute function Windows 8 Help with LEN and Substitute function Office 2013
Novice
Help with LEN and Substitute function
 
Join Date: Nov 2014
Posts: 6
Natalee is on a distinguished road
Default

Hi whatsup,

Update...It actually does work on a blank cell, as long as I do not add a number and then delete. This will work just fine overall.

Thanks,
Nat
Reply With Quote
  #5  
Old 11-08-2014, 05:28 AM
whatsup whatsup is offline Help with LEN and Substitute function Windows 7 64bit Help with LEN and Substitute function Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Quote:
...as long as I do not add a number and then delete
Now that seems to be a problem the way you delete the contains of a cell. Sticking to F20, if
= LEN(F20)
results in zero, then the formula will work correctly, if you insert for example <space> then it won't. Though the cell appears empty it isn't, and above formula will result in 1.

As explanation, with
OR(F20="",F20=0,F20="0")
you check three cases for F20:
- "" = the cell is empty or (as a result of a formula) contains an empty string
- 0 = the cell contains a 0 as number
- "0" = the cell contains a 0 as text (string)
in either case, the formula will return a fixed result of zero!!!
Reply With Quote
  #6  
Old 11-08-2014, 07:56 AM
Natalee Natalee is offline Help with LEN and Substitute function Windows 8 Help with LEN and Substitute function Office 2013
Novice
Help with LEN and Substitute function
 
Join Date: Nov 2014
Posts: 6
Natalee is on a distinguished road
Default

Thanks I see what you mean.

Nat
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with LEN and Substitute function #REF! Error in calling VBA function disappears when function is copied lcaretto Excel Programming 2 05-26-2014 07:19 PM
Creating a graph for Future Value function (FV function) bmoody Excel 2 11-06-2013 10:52 AM
Help with LEN and Substitute function Find & Replace: substitute red-coloured words with underscores tinfanide Word 2 10-06-2012 11:04 PM
Help with LEN and Substitute function how to use now() function gsrikanth Excel 1 01-07-2012 01:18 AM
if function help jim831 Excel 2 10-29-2010 07:06 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft