View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JenIT JenIT is offline
external usenet poster
 
Posts: 25
Default Macro to search range for a portion of a specific value and if findit - then paste formula in another cell.

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