View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Textbox text into cell as formula

You code worked for me, but this did as well which might be a bit more robust:

Private Sub CommandButton1_Click()
Dim s As String, sf as String
s = Trim(TextBox1.Text)
sf = ActiveCell.Numberformat
ActiveCell.NumberFormat = "General"
If Left(s, 1) < "=" Then
s = "=" & s
End If
ActiveCell.Formula = s
ActiveCell.Numberformat = sf
End Sub

--
Regards,
Tom Ogilvy



"Zone" wrote:

On my userform, I have a textbox that displays a formula from a cell.
I want to edit the formula in the textbox and, when I click OK, put the
text back into the cell as a formula.
activecell.formula = me.textbox1 puts it in as text. TIA, James