![]() |
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 ! |
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 ! |
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 ? |
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 ? |
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 |
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! |
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 |
All times are GMT +1. The time now is 10:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com