Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Adding FormatConditions in between other conditions

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
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
adding more than 3 conditions to a cell brillopad52 Excel Discussion (Misc queries) 17 April 16th 07 03:16 AM
FormatConditions VBA Bug? DaveCrowley Excel Programming 7 May 24th 06 09:52 PM
Adding OR conditions to IF-Then statement excelnut1954 Excel Programming 2 January 25th 06 08:38 PM
adding worksheets with conditions Niall D Excel Worksheet Functions 4 May 6th 05 10:25 AM
Adding more than three Conditions to 'Conditional Formatting' David McRitchie Excel Discussion (Misc queries) 1 November 27th 04 06:03 PM


All times are GMT +1. The time now is 01:19 PM.

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"