Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting a Graphic on a Button when the Button is Assigned to a M smck Excel Discussion (Misc queries) 2 October 27th 09 04:46 PM
Create floating button based on button click in menu ExcelMonkey Excel Programming 2 October 12th 05 06:43 PM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
Can't select macro button after other button is pressed C. Campbell Excel Programming 1 November 30th 04 07:46 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM


All times are GMT +1. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"