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: 293
Default Passing String to Formula1 Method in VB

I am trying to set conditional formatting to a volitile range of cells. I can
easily evaluate the formula to be pasted into the Conditional format box if
it is not volitile, i.e.

Formula1:="=$E$25=""N"""

However the Row and the Conditional Value are volitle so I can construct the
following string:

Dim MyText As String
MyText = "=$E$" & l.Row & Chr(61) & """""" & r.Cells(n, 15) & """"""

to pass to this statement

With r.Cells(n, 5)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression,
Formula1:=MyText

The formula either evalutes in VB as "TRUE" or "FALSE" before it passes to
the conditional format dilog box or If I add quotes passes the value "MyText"
to the Conditional Format dialog box.

What am I missing here. FYI the entire Macro is context is pasted below.

Sub Conditionals()

Worksheets("Checklist").Range("A26").Activate


Set r = Range("A26:Q574")
For n = 1 To r.Rows.Count
r.Cells(n, 1).Activate


Set c = (r.Cells(n, 14))
If c < "" Then

With Range("A2:A574")
Set l = .Find(c, LookIn:=xlValues)
If Not l Is Nothing Then
firstAddress = l.Address
Dim MyText As String
MyText = "=$E$" & l.Row & Chr(61) & """""" & r.Cells(n,
15) & """"""
Debug.Print MyText
With r.Cells(n, 5)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression,
Formula1:=MyText _
.FormatConditions(1).Interior.ColorIndex = 0
'Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=$E$25=""N"""

End With

End If
End With
End If
Next n
End Sub


 
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
Passing Query String into MS Excel napval Excel Discussion (Misc queries) 0 June 19th 07 06:04 AM
Using Find method in Excel passing more than 1 parameter Nick Excel Programming 3 November 2nd 04 05:56 PM
Passing a String in Array to Range as String [email protected] Excel Programming 2 September 1st 04 01:13 AM
string passing to DLL Christoph Wirz Excel Programming 1 February 20th 04 02:40 PM
PASSING A STRING VALUE Sirron Excel Programming 2 August 26th 03 06:40 PM


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