Hello
I am trying to use VBA to place a formula in a cell, but I keep getting a #Name? error.
I know why the error occurs. When the formula is placed in the cell by the code it looks like
when it should look like
How do I stop the formula from ending up with the apostrophes around the cell reference.
This is the entire piece of code
Sub Find_Stknmbr()
Dim FindString As String
Dim Rng As Range
FindString = Sheets("disposal").Range("ad2").Value
If Trim(FindString) <> "" Then
With Sheets("stock register list").Range("A2:a3000")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
ActiveCell.Offset(0, 13).Select
ActiveCell.FormulaR1C1 = "=disposal!bv11"
End If
End With
End If
End Sub
Thank you
Bookmarks