VBA input box help

FootBallBat

Board Regular
Joined
Jan 26, 2012
Messages
169
On: Sheets("Players") I have a command button, when clicked this runs:

Private Sub CommandButton1_Click()
Dim Player1 As Variant
Player1 = InputBox("Enter Player 1")
ActiveSheet.OLEObjects(1).Object.Caption = Player1
ActiveSheet.OLEObjects(1).Object.BackColor = 49152
End Sub


On: Sheets("Play") I have a command button. When it is clicked I want it to return the inputbox data from Sheets ("Players") to a corresponding cell, lets just say (A1)

If this is possible any help would be great. Thank you
 
.


Would it make more sense, when the user click on the "Grandpa" button, 'Grandpa" is automatically entered in Cell A1 on the other sheet ?

Can I then presume you want the other player names, as they appear on the buttons on the first sheet should be added to the second sheet, below Grandpa ?
Not exactly what I'm looking for but I can make that work. I can just hide the cells I put the info in.
How could I add that to the code to have the name placed in cell A1 on the sheet (Play)?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
.
Code:
Sub CommandButton1_Click()
    Dim Player1 As Variant
    Player1 = InputBox("Enter Player 1")
    ActiveSheet.CommandButton1.Caption = Player1
    ActiveSheet.CommandButton1.BackColor = 49151
    Sheets("Play").Range("A1").Value = Player1
End Sub
 
Upvote 0
.
Code:
Sub CommandButton1_Click()
    Dim Player1 As Variant
    Player1 = InputBox("Enter Player 1")
    ActiveSheet.CommandButton1.Caption = Player1
    ActiveSheet.CommandButton1.BackColor = 49151
    Sheets("Play").Range("A1").Value = Player1
End Sub
Works great, Thank you
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top