One button different actions

lvmoreira

New Member
Joined
May 20, 2008
Messages
10
Hello

I have a userform to fill a sheet with information about different students behaviour. I need to select the student number and fill a selection with information.

I need same help in two questions.

I use 10 commandbutton to select diferent cell on a sheet. (the student)

Question 1: Is possible to have a listbox to select diferent cell on a sheet?

I have 12 buttons. (Student behaviour)

The button 1 to 11 have this code:

Private Sub CommandButton1_Click()
ActiveCell.FormulaR1C1 = "AM"
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub

The button 12 have this code:

Private Sub CommandButton12_Click()
ActiveCell.FormulaR1C1 = "AM"
ActiveCell.Offset(1, -11).Range("A1").Select
End Sub

Question 2: Is possible to have just one button to do all the actions?

Thank you for your help.
Best regards.
Luís Moreira
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Luis

Why have so many buttons in the first place?

Perhaps if you clarified what you actually want to do we could help you, and could possibly involving a listbox.:)
 
Upvote 0
Norie thank for you reply.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
I will try to explain what i need.<o:p></o:p>
<o:p></o:p>
I want to make a form to a system call: Teacher behaviour.<o:p></o:p>
This system has 11 categories and we have to make a register every 5 sec.<o:p></o:p>
<o:p></o:p>
We can register the data using 2 methods:<o:p></o:p>
1 - We observe all the duration of the class<o:p></o:p>
2 - We use a sample of class time (X * 3min)<o:p></o:p>
<o:p></o:p>
After the user select the method the excel select a different sheet to collect data. <o:p></o:p>
<o:p></o:p>
If method 1 is select we have a user form with a 12 frames (Ex: 0-5 ... 55-60), in this frames we have the button for categories.<o:p></o:p>
Work just fine.<o:p></o:p>
<o:p></o:p>
If method 2 is select we have a form that works but we want to make it simple.<o:p></o:p>
<o:p></o:p>
I hope that explanation his sufficient for more help.<o:p></o:p>
 
Upvote 0
Not sure what you need. Another line to think along would be having cells labeled with what you want to record then using on select ---> row, column info to cumulate this information elsewhere.
 
Upvote 0
The button 1 to 11 have this code:

Private Sub CommandButton1_Click()
ActiveCell.FormulaR1C1 = "AM"
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
-----------
all 11 buttons have same codes?
 
Upvote 0
Hello

The 11 button's have this code

Private Sub CommandButton1_Click()
ActiveCell.FormulaR1C1 = "AM"
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub

the only change is the "AM"

Thank you

Best regards
Luís
 
Upvote 0
Try:
Code:
Private Sub CommandButton1_Click()
Dim n As Byte
n = InputBox("Please enter a number between 1-12", , Int(12 * Rnd + 1))
ActiveCell.FormulaR1C1 = Chr(n + 64) & "M"
ActiveCell.Offset(0, 1).Select
If n = 12 Then ActiveCell.Offset(1, -n).Select
End Sub

Regards
Northwolves
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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