Solved

Create function to color if line over # of characters

Posted on 2013-11-16
9
208 Views
Last Modified: 2014-11-12
Multiple lines can appear in a single cell.  I need a function since it is a shared Google doc and not a traditional Excel sheet.  The function should highlight any cells that contain a line over 20 characters.  

http://screencast.com/t/mChMFHOeh

Assistance is greatly appreciated.
0
Comment
Question by:frugalmule
  • 5
  • 4
9 Comments
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 500 total points
ID: 39654077
You can do thris through conditional formatting.
Select the column which has the text, such as A and go to conditional formatting: menu Home | Styles Conditional Formatting
Then select New Rule and pick Use a formula to determine which cells to format
In the text box enter: =LEN(A1)>20
Below that, pick a format, such as setting the text red and click OK until you're back on the spreadsheet.
Any cell with more than 20 characters will highlight as you specified.
0
 

Author Comment

by:frugalmule
ID: 39654083
The problem is that any 'cell' with more than 20 characters does not meet the requirement where any 'line' with more than 20 characters would meet the requirement.
0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 500 total points
ID: 39654871
Let's see what I can come up with...

Try changing the conditional format condition to this:

=LongestLine(A1)>20

Open in new window


Then add this in a new VB module (Alt+F8, menu Insert | Module):
Function LongestLine(Cell As Range) As Integer
    Dim iLongestLine As Integer
    Dim strLines() As String
    Dim iLineCntr As Integer
    
    strLines = Split(Cell, vbLf)
    iLongestLine = 0
    For iLineCntr = 0 To UBound(strLines)
        If Len(strLines(iLineCntr)) > iLongestLine Then
            iLongestLine = Len(strLines(iLineCntr))
        End If
    Next
    
    LongestLine = iLongestLine
End Function

Open in new window

0
 

Author Comment

by:frugalmule
ID: 39654895
The purpose of Google Docs is for sharing and the sharing component is far greater than what Office 360 can provide.

However, it limits us in some other ways.  This is the extent of what a google spreadsheet can do without a java script I think https://support.google.com/drive/table/25273?hl=en
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:frugalmule
ID: 39654905
Here is a depiction of the scripting capabilities because we are limited in the traditional sense http://screencast.com/t/sbeprYyJyU3y
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 39654937
So it appears you are looking for a GoogleDocs solution (but since you created the question in the Excel section, I thought you were looking for Excel.)
So I'm not really familiar with Google's spreadsheets, but based on your link I see this:

Text      SPLIT      SPLIT(string, delimiter, treat_delimiters_individually)

  This will be a bit of work, but you should be able to use this to check to see if any of the resulting items has a length > 20.  Alternately, you can use the FIND function to repeatedly search for the "newline" delimiter (which might be Code(13) or Code(10) or a combination of Code(13)&Code(10), depending on the source of the data.

I hope that using this info and the script I shared above, you can make it work.
0
 

Author Comment

by:frugalmule
ID: 39654952
I may have an alternate solution.  I think I can just reduce the columns and be able to tell which ones need changing that way.  Thanks for the tips.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39654960
You're welcome...I guess I need to start learning google sheets.
BTW...to use Code 13, you may need to use CHAR(13) in the split
0
 

Author Comment

by:frugalmule
ID: 39655004
Yeah, I really like them.

It would be nice to use macros but the ability to share comments on each cell and even restrict editing based on a range is pretty big plus for us.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many add-ons for Google docs, slides and sheets that can be extremely helpful in keeping your files organized and simple to use. Add-ons are installed into your Google docs, slides or sheets through Google's Add-On Store. One of my favorit…
The choice of selecting a perfect productive suite for one’s organization is a critical decision that an IT Manager or a CIO has to make. And when it comes to choosing a cloud-based productivity suite, the choice gets all the more difficult. This is…
This Micro Tutorial will demonstrate common damaging and frequent mistakes I see in most analytic audits. Most of them are campaign tagging mistakes, so this video will break it down into simple steps.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now