ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   return textfrom cell into textbutton/commandbutton (https://www.excelbanter.com/excel-programming/310288-return-textfrom-cell-into-textbutton-commandbutton.html)

Jonsson

return textfrom cell into textbutton/commandbutton
 
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes depending of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas



papou[_10_]

return textfrom cell into textbutton/commandbutton
 
Hello
Place this in the sheet's code and amend accordingly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$15" And Target.Value < "" Then
Me.CommandButton1.Caption = Target.Value
End If
End Sub

HTH
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes depending

of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas





Jonsson

return textfrom cell into textbutton/commandbutton
 
Hi Pascal

Thanks for your answer.

I'm sure the code is okay, but is it something I have to do to get the code
working in my application.
It seems to be some problem, because the macro wont work for me.
My button is'nt a commandButton, it's a textbutton (hope you know what I
mean). Could that be the problem?

"papou" skrev i meddelandet
...
Hello
Place this in the sheet's code and amend accordingly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$15" And Target.Value < "" Then
Me.CommandButton1.Caption = Target.Value
End If
End Sub

HTH
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes

depending
of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas







papou[_10_]

return textfrom cell into textbutton/commandbutton
 
Where did you get the "textbutton" from:
Forms tool bar
Controls Tool Box
?
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi Pascal

Thanks for your answer.

I'm sure the code is okay, but is it something I have to do to get the

code
working in my application.
It seems to be some problem, because the macro wont work for me.
My button is'nt a commandButton, it's a textbutton (hope you know what I
mean). Could that be the problem?

"papou" skrev i meddelandet
...
Hello
Place this in the sheet's code and amend accordingly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$15" And Target.Value < "" Then
Me.CommandButton1.Caption = Target.Value
End If
End Sub

HTH
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes

depending
of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas









Jonsson

return textfrom cell into textbutton/commandbutton
 
Forms Toolbar

//Thomas
"papou" skrev i meddelandet
...
Where did you get the "textbutton" from:
Forms tool bar
Controls Tool Box
?
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi Pascal

Thanks for your answer.

I'm sure the code is okay, but is it something I have to do to get the

code
working in my application.
It seems to be some problem, because the macro wont work for me.
My button is'nt a commandButton, it's a textbutton (hope you know what I
mean). Could that be the problem?

"papou" skrev i meddelandet
...
Hello
Place this in the sheet's code and amend accordingly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$15" And Target.Value < "" Then
Me.CommandButton1.Caption = Target.Value
End If
End Sub

HTH
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes

depending
of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas











Papou

return textfrom cell into textbutton/commandbutton
 
Hello
This is what I "feared".
I would personnaly rather recommend you use one of the controls tool box
items instead.
As it will be definitely easier for you to access its properties (Value or
Caption for instance).
In the sample code I provided previously you will note that I am using the
key word "Me" which identifies the worksheet since you are dealing with this
object class when you are in the Worksheet code (right-clicking on the
worksheet tab and selecting view code brings you there)
Using this method will automatically provide access to any property or
object related to the worksheet using the dot (.)
Thus if you have previoulsy created a commandbutton for example (from the
controls tool box) and by default its name will be CommandButton1, if you
use the word Me followed by the dot (ie: Me.) then you will have a pop up
list with all the available items among which you will find the object
"CommandButton1".
Hope this helps you get on further.

Cordially
Pascal


"Jonsson" a écrit dans le message de
...
Forms Toolbar

//Thomas
"papou" skrev i meddelandet
...
Where did you get the "textbutton" from:
Forms tool bar
Controls Tool Box
?
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi Pascal

Thanks for your answer.

I'm sure the code is okay, but is it something I have to do to get the

code
working in my application.
It seems to be some problem, because the macro wont work for me.
My button is'nt a commandButton, it's a textbutton (hope you know what

I
mean). Could that be the problem?

"papou" skrev i meddelandet
...
Hello
Place this in the sheet's code and amend accordingly:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$15" And Target.Value < "" Then
Me.CommandButton1.Caption = Target.Value
End If
End Sub

HTH
Cordially
Pascal

"Jonsson" a écrit dans le message de
...
Hi all,

Is it possible to return a textvalue from a cell into a
textbutton/commandbutton so that the text in the button changes
depending
of
what you write in the cell?
If so, how to do it?

Any help is apprecciated!!

//Thomas














All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com