Building criteria string for Advanced Filter variable not resolvin

G

Guest

I am building a criteria string for an Advanced Filter feature. The string
values exist in a spreadsheet. I need to prepend ="= and append a trailing
quote. When I do the varialbe myCriteria does not resolve. Here is the code
snippet:

Dim iRow As Intege
Dim myCriteria As String
iRow = 2
For Each c In Worksheets("WatchCriteria").Range("A2:A19")
If c.Value <> "" Then
myCriteria = c.Value
Worksheets("WatchList").Range(Cells(iRow, 2), Cells(iRow, 2)).Formula
= "=""=myCriteria"""
iRow = iRow + 1
End If
Next c

I want the actual value of the myCriteria variable to resolve within the
cell. Instead I get
="=myCriteria"

Can anyone suggest a way to do this?
 
G

Guest

try:

Dim iRow As Integer
Dim myCriteria As String
iRow = 2
For Each c In Worksheets("WatchCriteria").Range("A2:A19")
If c.Value <> "" Then
myCriteria = "=" & c.Value
Worksheets("WatchList").Range("B" & iRow).Formula = myCriteria
iRow = iRow + 1
End If
Next c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top