View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Macro to search range for a portion of a specific value and if find it - then paste formula in another cell.

On Tue, 5 Mar 2013 13:32:26 -0800 (PST), JenIT wrote:

The below formula works as written for a set value of "66-1007" in column B. My problem is I need to search for a portion of that value as the 66-10 will remain constant, but the last 2 numbers might change (it is always a 7 character field). I have tried the * and # variables and have not had luck. Any help would be appreciated.

With Sheets("myworkshet")
Set rngToSearch = .Range(.Range("B2"), _
.Cells(Rows.Count, "B").End(xlUp))
End With

For Each rng In rngToSearch
With rng
If .Value = "66-1007" Then
Cells(.Row, "K").FormulaR1C1 = "=(RC[6]+RC[7])*0.08615"
End If
End With
Next rng


Look at help for Like:

Try: if .value like "66-10##" then