LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Another Cell formatting Question.

I got a very good answer to a question in here just the other day, and it
works great! I'm trying to add to it now though, and can't figure out how
to get it to work.

Here's the code Mr. Ogilvy so graciously supplied, which as I said works
great:

Public Function NoDash(rng As Range)

Dim sStr As String
sStr = ""
For Each cell In rng
sStr = sStr & cell.Value & "," & Chr(10)
Next
sStr = Left(sStr, Len(sStr) - 2)
NoDash = sStr

End Function

However, for the cell to be "formatted" correctly, it needs to have the wrap
text attribute set to true.

I use a second function to strip just the portion after the dash(if it
exists) as well, like this:

Function RightOfDash(S As String) As String

Dim Pos As Integer
Pos = InStr(1, S, "-", vbTextCompare)
If Pos 0 Then
RightOfDash = Mid(S, Pos + 1)
Else
RightOfDash = S
End If
End Function

What I'd like to do is us an if statement in the cell to decide which of
these to run, something like this:
=(IF(ISNUMBER(FIND("-",'Veh 1 Data'!J1)),rightofdash('Veh 1
Data'!J1)&","&rightofdash('Veh 1 Data'!J2)&","&rightofdash('Veh 1
Data'!J3)&","&rightofdash('Veh 1 Data'!J4),NoDash('Veh 1 Data'!J1:J4)))

But, I can't figure out how to turn the wrap text attribute on if the dash
doesn't exist, and turn it off if it does. I've tried using :
Worksheets("Tire Wear Summary").Range("C15").WrapText = (then set to true or
false, depending on which function it's in), but this has no effect.

Is there any way to accomplish this? If not, it's no big deal, I can keep
the two as separate workbooks and run the appropriate one, but if I can
somehow set the wrap attribute on the fly as it were, I can combine the two
into one workbook.

Thanks!
Shawn


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell formatting question ManhattanRebel Excel Discussion (Misc queries) 4 July 30th 08 03:37 AM
Cell Formatting Question carl Excel Worksheet Functions 3 June 15th 07 07:27 PM
Conditional Formatting question (if cell = 0, wrap cell in quotes) Mo2 New Users to Excel 6 May 11th 07 11:06 PM
Cell formatting behaviour question derek Excel Discussion (Misc queries) 3 February 22nd 05 10:17 PM
Cell formatting question Wexler[_2_] Excel Programming 1 December 6th 04 10:31 PM


All times are GMT +1. The time now is 07:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"