PC Review


Reply
Thread Tools Rate Thread

Adding FormatConditions in between other conditions

 
 
J Streger
Guest
Posts: n/a
 
      31st Mar 2008
I'm using Excel 2003, and trying to write a method that will insert a format
condition at the passed in index. I know that to do this I essentially need
to delete the old conditions and re-add. Regardless I have the below, but it
seems the formatconditions objects are not new object and keep their link the
the original formatting, so if that formatting is deleted, so it the
variables data. Does anyone know if this can be done? Below is what I was
working on so far.

Public Sub InsertConditionalFormat(ByVal index As Integer, rCell As Range, _
formatCondition As formatCondition)

Dim cfShift As formatCondition
Dim colFC As New Collection

'First get format conditions of old cell
For Each cfShift In rCell.FormatConditions

colFC.Add cfShift

Next cfShift

rCell.FormatConditions.Delete

'Now insert new format condition where they want it
If index <= colFC.Count And colFC.Count < 3 Then

colFC.Add formatCondition, , index

End If

'Add format conditions back to the cell
For index = 1 To colFC.Count

Set cfShift = colFC(index)

rCell.FormatConditions.Add cfShift.Type, Formula1:=cfShift.Formula1

'rCell.FormatConditions(index) = cfShift

Next index

End Sub

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding more than 3 conditions to a cell =?Utf-8?B?YnJpbGxvcGFkNTI=?= Microsoft Excel Misc 17 16th Apr 2007 03:16 AM
Adding multiple solver conditions in VBA Mark Hann Microsoft Excel Programming 0 11th Sep 2006 01:14 AM
Adding OR conditions to IF-Then statement excelnut1954 Microsoft Excel Programming 2 25th Jan 2006 08:38 PM
adding worksheets with conditions =?Utf-8?B?TmlhbGwgRA==?= Microsoft Excel Worksheet Functions 4 6th May 2005 10:25 AM
Adding with multiple conditions Gavin Robertson Microsoft Excel Worksheet Functions 0 10th Sep 2003 06:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 AM.