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: 4
Default Ensuring Conditional formating is not lost

I have defined conditional formating for a range of cells in my
spreadsheet. What I need is a macro to ensure that if a user copies and
pastes into these cells the conditional formating is not lost. Any
ideas greatly appreciated?

My efforts so far are to display a warning message and undo the action
as below, although it does not work for multiple cells. If I have one
cell in my range I can check that formatConditions.count 1 i.e there
is still some formatting. However the results are unpredictable if I
use a range of multiple cells.


Private Sub Worksheet_Change(ByVal Target As Range)

'Does the range still have conditional formating?

If HasValidation(Worksheets("Sheet1").Range("casefill ")) Then
Exit Sub
Else

MsgBox "Data paste not allowed please use paste special. " & _
"See help for further details", vbCritical

'Application.Undo

End If
End Sub

Private Function HasValidation(r) As Boolean
' Return True if every cell in Range r uses Conditional Formating

Dim x As Integer

x = 0
x = r.FormatConditions.count
Debug.Print "count: " & x
If x 0 Then HasValidation = True Else HasValidation = False

End Function

 
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
Ensuring 3 cells do NOT match GIdunno Excel Discussion (Misc queries) 12 September 6th 07 09:36 PM
Office 2007-Source formating lost when emailing from excel csi.sec Excel Discussion (Misc queries) 4 February 6th 07 07:24 AM
Office 2007-Source formating lost when emailing from excel csi.sec Excel Discussion (Misc queries) 0 February 5th 07 04:47 AM
Install dates formating using conditional formating? Jerry Eggleston Excel Discussion (Misc queries) 2 November 9th 05 05:49 PM
there must be a better way - ensuring userforms are closed JulieD Excel Programming 10 September 7th 04 10:36 AM


All times are GMT +1. The time now is 11:31 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"