Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
I've inserted a command button and recorded (very simple):
Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
So you grabbed a button off of the control toolbox and placed it on your
sheet. You recorded a macro and copied the code that was recorded into the command button's click event. (you got the click event code stub by double clicking the command button) I assume that my description is accurate so far? When you added the button your sheet is in Design Mode. That mode allows you to interact with the button without triggering the code to run. In order to make the button operable you need to exit design mode. The first button on the control toolbox looks like a triangle and ruler. Click that button to exit design mode. Your button should now work correctly. You could tighten up your code a bit as follows if you want... Private Sub CommandButton2_Click() 'does not select the cell With Range("F9").Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub -- HTH... Jim Thomlinson "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
what does the VBA screen say? (assume you mean it give you an error message).
Also, what version of excel are you using. -- Regards, Tom Ogilvy "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
It sounds like you may be still in design mode.
If you're using xl2003 menus, there's a design mode icon on the Control toolbox toolbar. Click that to toggle in and out of that state. Private Sub CommandButton2_Click() With me.range("F9") .ColorIndex = 43 .Pattern = xlSolid End With End Sub (dropping the selection.) max wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
Good catch. I guess he meant double clicked the button.
-- Regards, Tom Ogilvy "Jim Thomlinson" wrote: So you grabbed a button off of the control toolbox and placed it on your sheet. You recorded a macro and copied the code that was recorded into the command button's click event. (you got the click event code stub by double clicking the command button) I assume that my description is accurate so far? When you added the button your sheet is in Design Mode. That mode allows you to interact with the button without triggering the code to run. In order to make the button operable you need to exit design mode. The first button on the control toolbox looks like a triangle and ruler. Click that button to exit design mode. Your button should now work correctly. You could tighten up your code a bit as follows if you want... Private Sub CommandButton2_Click() 'does not select the cell With Range("F9").Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub -- HTH... Jim Thomlinson "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
That is my best guess. Nice to have you back. We missed you. General
interest... Where did you get to. Somewhere good I hope. -- HTH... Jim Thomlinson "Tom Ogilvy" wrote: Good catch. I guess he meant double clicked the button. -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: So you grabbed a button off of the control toolbox and placed it on your sheet. You recorded a macro and copied the code that was recorded into the command button's click event. (you got the click event code stub by double clicking the command button) I assume that my description is accurate so far? When you added the button your sheet is in Design Mode. That mode allows you to interact with the button without triggering the code to run. In order to make the button operable you need to exit design mode. The first button on the control toolbox looks like a triangle and ruler. Click that button to exit design mode. Your button should now work correctly. You could tighten up your code a bit as follows if you want... Private Sub CommandButton2_Click() 'does not select the cell With Range("F9").Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub -- HTH... Jim Thomlinson "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
Jim,
I didn't go anywhere - specifically I didn't go here <g -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: That is my best guess. Nice to have you back. We missed you. General interest... Where did you get to. Somewhere good I hope. -- HTH... Jim Thomlinson "Tom Ogilvy" wrote: Good catch. I guess he meant double clicked the button. -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: So you grabbed a button off of the control toolbox and placed it on your sheet. You recorded a macro and copied the code that was recorded into the command button's click event. (you got the click event code stub by double clicking the command button) I assume that my description is accurate so far? When you added the button your sheet is in Design Mode. That mode allows you to interact with the button without triggering the code to run. In order to make the button operable you need to exit design mode. The first button on the control toolbox looks like a triangle and ruler. Click that button to exit design mode. Your button should now work correctly. You could tighten up your code a bit as follows if you want... Private Sub CommandButton2_Click() 'does not select the cell With Range("F9").Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub -- HTH... Jim Thomlinson "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
You took a break from answering questions??? My sense of world order is
feeling a bit off knowing that. Death, taxes and Tom will answer the question before you do. There are so few things you can count on in the world... <g -- HTH... Jim Thomlinson "Tom Ogilvy" wrote: Jim, I didn't go anywhere - specifically I didn't go here <g -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: That is my best guess. Nice to have you back. We missed you. General interest... Where did you get to. Somewhere good I hope. -- HTH... Jim Thomlinson "Tom Ogilvy" wrote: Good catch. I guess he meant double clicked the button. -- Regards, Tom Ogilvy "Jim Thomlinson" wrote: So you grabbed a button off of the control toolbox and placed it on your sheet. You recorded a macro and copied the code that was recorded into the command button's click event. (you got the click event code stub by double clicking the command button) I assume that my description is accurate so far? When you added the button your sheet is in Design Mode. That mode allows you to interact with the button without triggering the code to run. In order to make the button operable you need to exit design mode. The first button on the control toolbox looks like a triangle and ruler. Click that button to exit design mode. Your button should now work correctly. You could tighten up your code a bit as follows if you want... Private Sub CommandButton2_Click() 'does not select the cell With Range("F9").Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub -- HTH... Jim Thomlinson "max" wrote: I've inserted a command button and recorded (very simple): Private Sub CommandButton2_Click() Range("F9").Select With Selection.Interior .ColorIndex = 43 .Pattern = xlSolid End With End Sub When I click the button, it takes me to the VBA screen. what am I doing wrong? |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Never used a button before
Great seeing you again, Tom :-)
Best wishes Harald "Tom Ogilvy" wrote in message ... Jim, I didn't go anywhere - specifically I didn't go here <g -- Regards, Tom Ogilvy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Inserting a Graphic on a Button when the Button is Assigned to a M | Excel Discussion (Misc queries) | |||
Create floating button based on button click in menu | Excel Programming | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
Can't select macro button after other button is pressed | Excel Programming | |||
Delete a custom button by holding down the ALT key and dragging the button off the toolbar | Excel Programming |