Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FormatConditions VBA Bug?


Hi Guys,

I currently have the pleasure of having to get up to speed with some
undocumented spreadsheets. To aid me, I'd like to visually identify all
formulas within these spreadsheets. I have been able to do this manually
successfully using "Conditional Formatting..." and a user defined
function (see below).

This feature worked a treat but having it switched on all the time
appeared to degrade performance. Therefore I tried to create two
macros. One macro to enable "Conditional formatting..." for all cells
in the current sheet, and a second macro to disable it. That way I can
switch it on and off as required. The macro to disable/delete the
"Conditional formatting" works a treat but the macro to enable it does
not. Stepping through the code (see below), it executes the first three
statements in the macro, then exits the routine.

Am I doing something silly or have I unearthed a bug? Any advise/help
would be highly appreciated.

Cheers, Dave.


Function IsFormula(Check_Cell As Range)

IsFormula = Check_Cell.HasFormula

End Function

Sub Show_Formulas_in_Current_Sheet()

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IsFormula(A1)"
With Selection.FormatConditions(1).Borders(xlLeft)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlRight)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlTop)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With

End Sub


--
DaveCrowley
------------------------------------------------------------------------
DaveCrowley's Profile: http://www.excelforum.com/member.php...o&userid=34762
View this thread: http://www.excelforum.com/showthread...hreadid=545228

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default FormatConditions VBA Bug?

Hi Dave,

could it happen that selection already contains conditionally formatted
cells?

then:

Sub Show_Formulas_in_Current_Sheet()

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.FormatConditions.Delete 'added
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IsFormula(A1)"
With Selection.FormatConditions(1).Borders(xlLeft)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlRight)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlTop)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = 3
End With

End Sub

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FormatConditions VBA Bug?


Thanks Ivan.

I tried your suggestion but the problem persists. Are you able to
perhaps recreate the problem? I want to try and eliminate a bad
install/image of Excel as the cause of the problem.

Cheers, Dave.


--
DaveCrowley
------------------------------------------------------------------------
DaveCrowley's Profile: http://www.excelforum.com/member.php...o&userid=34762
View this thread: http://www.excelforum.com/showthread...hreadid=545228

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default FormatConditions VBA Bug?

Hi Dave,

but your code works.

I don't know what you intended, but when I select a1 (which contains a
formula), the conditional formatting is applied to a1 without any
problems.

I can't recall reliably, I had to apply conditional formatting cell by
cell when I needed to do it programmaticaly. It was not possible to do
it for more cells at once.

Regards,
Ivan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default FormatConditions VBA Bug?

Hi Dave,

now I recalled how I solved the problem with conditional formatting. I
exported the module, opened in notepad, added one line:
Attribute Macro1.VB_ProcData.VB_Invoke_Func = " \n14"
just below the sub somename().

Regards,
Ivan



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default FormatConditions VBA Bug?

sorry, incidentally posted before finished

so, after you add the line, import the module back. You will not see
the line in VBA editor (the more, you will not be able to add it in VBA
editor).

I don't know what exactly the line means, I found it while comparing in
notepad recorded macro and written macro - this was the only difference
(besides that the recorded macro worked and written didn't).

Regards,
Ivan

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default FormatConditions VBA Bug?

this may be easier

Sub borderaround()
Range("A1", Range("a1").SpecialCells(xlLastCell)) _
..borderaround ColorIndex:=3
End Sub


--
Don Guillett
SalesAid Software

"DaveCrowley"
wrote in message
...

Hi Guys,

I currently have the pleasure of having to get up to speed with some
undocumented spreadsheets. To aid me, I'd like to visually identify all
formulas within these spreadsheets. I have been able to do this manually
successfully using "Conditional Formatting..." and a user defined
function (see below).

This feature worked a treat but having it switched on all the time
appeared to degrade performance. Therefore I tried to create two
macros. One macro to enable "Conditional formatting..." for all cells
in the current sheet, and a second macro to disable it. That way I can
switch it on and off as required. The macro to disable/delete the
"Conditional formatting" works a treat but the macro to enable it does
not. Stepping through the code (see below), it executes the first three
statements in the macro, then exits the routine.

Am I doing something silly or have I unearthed a bug? Any advise/help
would be highly appreciated.

Cheers, Dave.


Function IsFormula(Check_Cell As Range)

IsFormula = Check_Cell.HasFormula

End Function

Sub Show_Formulas_in_Current_Sheet()

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=IsFormula(A1)"
With Selection.FormatConditions(1).Borders(xlLeft)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlRight)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlTop)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = 3
End With
With Selection.FormatConditions(1).Borders(xlBottom)
LineStyle = xlContinuous
Weight = xlThin
ColorIndex = 3
End With

End Sub


--
DaveCrowley
------------------------------------------------------------------------
DaveCrowley's Profile:
http://www.excelforum.com/member.php...o&userid=34762
View this thread: http://www.excelforum.com/showthread...hreadid=545228



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default FormatConditions VBA Bug?


Thanks for the suggest Don. How would I use this code snippet with
"FormatConditions.Add Type"?

Cheers, Dave.


--
DaveCrowley
------------------------------------------------------------------------
DaveCrowley's Profile: http://www.excelforum.com/member.php...o&userid=34762
View this thread: http://www.excelforum.com/showthread...hreadid=545228

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
FormatConditions(1).Formula1 Stefi Excel Programming 9 February 17th 06 10:37 AM
FormatConditions appears to kill copypaste [email protected] Excel Programming 2 October 18th 05 11:06 PM
Bug in .FormatConditions.Add Type:=xlExpression, Formula1:=cfExpression Thief_ Excel Worksheet Functions 3 April 19th 05 02:26 AM
FormatConditions (fails in different Languages) DamiaoBR[_2_] Excel Programming 0 May 12th 04 01:54 AM
font size on formatconditions Chip Pearson Excel Programming 0 August 13th 03 02:09 PM


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