Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Message box [how it works??]

i've inserted a toggle button in my excel sheet (sheet "ratings").
i want, by clickin' on it, a message box to appear.
the text of this message box is allocated on a cell of a different
sheet (named: labels) of the same excel file.

if i put these lines on togglebutton code:

Private Sub ToggleButton1_Click()
text = Range("labels!A980").Value
MsgBox (text)
End Sub

it doesn't work!

if i write a macro named 'totali'
and associate it to toggle button code it works. why??

here's the effective code that works :

Sub totali()
Dim testo As String
text = Range("labels!A980").Value
MsgBox (text)
End Sub

Private Sub ToggleButton1_Click()
Application.Run "My.T.y.M.xls!totali"
End Sub

thanks !

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Message box [how it works??]

Because you have used a button from the Forms toolbar. The Click macro
applies to a control toolbox button.

--
HTH

Bob Phillips

"furbiuzzu" wrote in message
oups.com...
i've inserted a toggle button in my excel sheet (sheet "ratings").
i want, by clickin' on it, a message box to appear.
the text of this message box is allocated on a cell of a different
sheet (named: labels) of the same excel file.

if i put these lines on togglebutton code:

Private Sub ToggleButton1_Click()
text = Range("labels!A980").Value
MsgBox (text)
End Sub

it doesn't work!

if i write a macro named 'totali'
and associate it to toggle button code it works. why??

here's the effective code that works :

Sub totali()
Dim testo As String
text = Range("labels!A980").Value
MsgBox (text)
End Sub

Private Sub ToggleButton1_Click()
Application.Run "My.T.y.M.xls!totali"
End Sub

thanks !



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Message box [how it works??]

thanks 4 answering.

but i'm a newenewnewbie in programming with VB.
there's not a way to disply the msgbox i want with just one click on a
toggle button ?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Message box [how it works??]

Rightclick the button, choose "assign macro" and assign the Totali macro to
it.

HTH. Best wishes Harald

"furbiuzzu" skrev i melding
oups.com...
thanks 4 answering.

but i'm a newenewnewbie in programming with VB.
there's not a way to disply the msgbox i want with just one click on a
toggle button ?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Message box [how it works??]

I think you used the correct togglebutton for your code (from the Control
toolbox toolbar, right?).

But I think your code is confusing excel.

Try this:

Option Explicit
Private Sub ToggleButton1_Click()
Dim myText As Variant
myText = Worksheets("labels").Range("a980").Value
MsgBox myText
End Sub

(Text is a property that VBA uses. I try to stay away from them--that confuses
me--even if VBA can figure it out.)

But this line:

text = Range("labels!A980").Value

has an unqualifed range object. In a general module, that range syntax would
work ok. But under a worksheet module, excel thinks you mean a range on the
sheet that owns the code (and Labels is a different sheet, right?).

You could have used something like this, too:
myText = Application.Range("labels!A980").Value

But I like this first way lots mo
myText = Worksheets("labels").Range("a980").Value

I find it easier to read later on (when I'm correcting my other mistakes).

furbiuzzu wrote:

i've inserted a toggle button in my excel sheet (sheet "ratings").
i want, by clickin' on it, a message box to appear.
the text of this message box is allocated on a cell of a different
sheet (named: labels) of the same excel file.

if i put these lines on togglebutton code:

Private Sub ToggleButton1_Click()
text = Range("labels!A980").Value
MsgBox (text)
End Sub

it doesn't work!

if i write a macro named 'totali'
and associate it to toggle button code it works. why??

here's the effective code that works :

Sub totali()
Dim testo As String
text = Range("labels!A980").Value
MsgBox (text)
End Sub

Private Sub ToggleButton1_Click()
Application.Run "My.T.y.M.xls!totali"
End Sub

thanks !


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Message box [how it works??]

really thanks

myText = Worksheets("labels").Range("a9*80").Value

is what i meant to write.

it works, and , as you saud, is very easy to read.

sorry for my newbie questions!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Message box [how it works??]

Nothing to be sorry about.

Glad you got it working.

furbiuzzu wrote:

really thanks

myText = Worksheets("labels").Range("a9*80").Value

is what i meant to write.

it works, and , as you saud, is very easy to read.

sorry for my newbie questions!


--

Dave Peterson
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
Need help on how it works.... deepak Excel Discussion (Misc queries) 1 January 28th 09 08:01 AM
It works but why...? will Links and Linking in Excel 13 October 14th 05 05:39 PM
How do I convert works file to excel without works software? CatMB Excel Discussion (Misc queries) 1 June 21st 05 04:12 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM
Displaying a message in a message box without requiring user to click anything to proceed Android[_2_] Excel Programming 2 June 25th 04 06:44 PM


All times are GMT +1. The time now is 11:04 AM.

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

About Us

"It's about Microsoft Excel"