![]() |
Building criteria string for Advanced Filter variable not resolvin
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? |
Building criteria string for Advanced Filter variable not resolvin
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 "JEFFWI" wrote: 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? |
All times are GMT +1. The time now is 06:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com