PC Review


Reply
Thread Tools Rate Thread

Changing a formula inside a textbox - Excel 2007

 
 
benspain_uk@hotmail.com
Guest
Posts: n/a
 
      9th Jan 2008
I am trying to find a way to change and view the formula inside a
textbox on a worksheet using VBA within Excel 2007.

In 2003 I use:

strButtonFormula = wsSheet.TextBoxes(strButtonName).Formula

and

wsSheet.TextBoxes(strButtonName).Formula = "=A1"

Nice and easy, and I have no issues.


However in 2007 - it doesn't like this code, and I can't find a way to
use "shapes" to get the same thing. I can get the text (i.e.
wsSheet.Shapes(strButtonName).TextFrame.Characters.Text), but not the
formula.

Also, when I record a macro in 2007, I get "ActiveCell.FormulaR1C1 =
"R1C1"", however this just doesn't work - it changes the last selected
cell, not the textbox!

Any ideas?????
 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      9th Jan 2008
Hmm...

What do you mean XL2007 "doesn't like this code"?


It works for me, as long as the variables are assigned appropriately.

In article
<7da6ac83-4d6b-4486-921a-(E-Mail Removed)>,
(E-Mail Removed) wrote:

> I am trying to find a way to change and view the formula inside a
> textbox on a worksheet using VBA within Excel 2007.
>
> In 2003 I use:
>
> strButtonFormula = wsSheet.TextBoxes(strButtonName).Formula
>
> and
>
> wsSheet.TextBoxes(strButtonName).Formula = "=A1"
>
> Nice and easy, and I have no issues.
>
>
> However in 2007 - it doesn't like this code, and I can't find a way to
> use "shapes" to get the same thing. I can get the text (i.e.
> wsSheet.Shapes(strButtonName).TextFrame.Characters.Text), but not the
> formula.
>
> Also, when I record a macro in 2007, I get "ActiveCell.FormulaR1C1 =
> "R1C1"", however this just doesn't work - it changes the last selected
> cell, not the textbox!
>
> Any ideas?????

 
Reply With Quote
 
benspain_uk@hotmail.com
Guest
Posts: n/a
 
      9th Jan 2008
When I try:

strButtonFormula = wsSheet.TextBoxes(strButtonName).Formula

I get

"run-time error '1004'
Unable to get the TextBoxes property of the Worksheet class"

(Both variables are declared as strings)
 
Reply With Quote
 
benspain_uk@hotmail.com
Guest
Posts: n/a
 
      9th Jan 2008
Do I need to simply add a reference?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing color of a string inside an asp.net textbox jc Microsoft ASP .NET 4 19th Jun 2008 09:12 PM
Re: Copy formula without changing references [Excel 2007] Jim Rech Microsoft Excel Discussion 1 8th May 2008 12:15 AM
Excel 2003, can't setfocus in a textbox inside a multipage, tab key don work! carlosla Microsoft Excel Programming 0 23rd Feb 2006 07:55 PM
how do i use a formula inside of a cell reference in Excel =?Utf-8?B?bWg=?= Microsoft Excel Worksheet Functions 2 7th Oct 2004 11:45 PM
Excel Function/Formula help...Variable inside a SumIf ? tj832006 Microsoft Excel Worksheet Functions 2 1st Mar 2004 06:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.