LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Conditional Formatting Challenge

Hi Rick, I put the Nothing criteria in out of habit to avoid messages in
case it does not find anything. But you are right, it is superflous in this
case. The whole point was to illustrate that 'apple" can be found no matter
how many spaces it has or what other data may be in the cell. I don't
believe either of our snippets will answer the question of conditional
formatting to do the same job, however.

"Rick Rothstein" wrote:

Two comments on your code...

First, I don't think the 'c' variable can ever be Nothing, so you should be
able to remove that test. Second, I think using an InStr test instead of the
Like comparison might be better for that particular search (case insensitive
word). Maybe this...

Sub MIT()
Dim C As Range
For Each C In Sheets(1).UsedRange
If InStr(1, C.Value, "apple", vbTextCompare) Then
C.Interior.ColorIndex = 3
End If
Next
End Sub

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
I am not sure what you are looking for, but this snippet will find apple,
regardless of the spaces or capitalization or what comes before or after
it.

Sub mit()
For Each c In Sheets(1).UsedRange 'Change to suit
If Not c Is Nothing Then
If UCase(c.Value) Like "*APPLE*" Then
c.Interior.ColorIndex = 3
End If
End If
Next
End Sub


"Exceller" wrote:

I've searched both posts here and on the internet, but have not found a
solution to my issue. I work in general ledgers all day and need to be
able
to format the sheet whereby any instance of a particular account gets
highlighted, wherever it is on the worksheet. The problem with my
particular
circumstance is that there can be various permutations of the Account
Name,
depending on the number of spaces in front of it. The number of spaces
that
are placed before the account name is highly variable and is determined
by
the amount of "drill down" I do in the account hierarcy.

For the sake of simplicity, say I have accounts "Apple", "Orange" and
"Pear". Depending on how far down I drill on the Apple account (or other
accounts) it can appear as ' Apple, or ' Apple, or any variant of
"Apple" and preceding spaces. Note that there is an apostraphe, then any
number of spaces and then the account name. I've tried various formulae
in
the Conditional Formatting utility in Excel and have not been able to
"get
there", including Clean(Trim(xxxxxx and Find( and Search( functions.
I'd
rather have this in VBA anyway.

So, in closing, If "Apple" is found anywhere on the worksheet, regardless
of
how many spaces exist between the beginning apostrophe and the account
name I
want it --and the next 10 cells to the right highlight yellow and have a
border box around the range.

Is this do-able?

Thanks.




 
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
Excel 2003 Conditional formatting challenge question John C. Excel Discussion (Misc queries) 11 November 9th 09 05:11 PM
Challenge - Excel Line Feed Character CHR(10) - How to Delete and keep the text formatting without going ro single line in a cell ? No Name Excel Worksheet Functions 7 October 7th 09 11:10 AM
Real Data Formatting Challenge Pat Excel Discussion (Misc queries) 3 November 25th 08 07:51 PM
Challenge with conditional find Vic[_4_] Excel Programming 3 May 13th 07 02:40 AM
conditional formatting challenge brendan Excel Discussion (Misc queries) 2 October 18th 05 08:28 AM


All times are GMT +1. The time now is 04:00 AM.

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

About Us

"It's about Microsoft Excel"