Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Textbox text into cell as formula

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Textbox text into cell as formula

I dont know what's in your textbox.. but
ActiveCell.Formula = "=Sum(b1:b10)" works for me.

Your routine must check that the string starts with "="

NOTE:
Personally I'd use FormulaLOCAL to interact between textbox and range.
as this will contain the language and separators the user expects.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Zone wrote in
roups.com

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Textbox text into cell as formula

Thanks, Cool. I subsequently found that the text needed to be trimmed
for some reason. I'll look into your suggestions, though. Cheers,
James
keepITcool wrote:
I dont know what's in your textbox.. but
ActiveCell.Formula = "=Sum(b1:b10)" works for me.

Your routine must check that the string starts with "="

NOTE:
Personally I'd use FormulaLOCAL to interact between textbox and range.
as this will contain the language and separators the user expects.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Zone wrote in
roups.com

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
move text from form textbox to next blank cell thomas Excel Programming 1 July 26th 05 01:45 AM
take text from form textbox and put in cell... thomas Excel Programming 1 July 26th 05 01:35 AM
Filling a textbox with text in another cell Charles Excel Programming 2 August 19th 04 01:32 AM
Copy range Cell text and font properties to a Textbox BC[_3_] Excel Programming 3 March 3rd 04 07:32 PM
check variable(text) with cell (text), textbox Mark[_17_] Excel Programming 1 August 27th 03 01:15 PM


All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"