Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Command Button

I have a coomand button that should select a sheet and change the value in a
cell.
The code I have used is as follows, but it generates an error.

Private Sub CommandButton2_Click()
Sheets("Customer Profile").Select
Range("newused") = 1
End Sub

Please advise weere I am going wrong.

Thanks in advance of a favourable reply.
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Command Button

hi
what error is it generating?

regards
FSt1

"John Excel" wrote:

I have a coomand button that should select a sheet and change the value in a
cell.
The code I have used is as follows, but it generates an error.

Private Sub CommandButton2_Click()
Sheets("Customer Profile").Select
Range("newused") = 1
End Sub

Please advise weere I am going wrong.

Thanks in advance of a favourable reply.
John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Command Button

1. check if there is a worksheet named "Customer Profile" in yr
workbook
2. check if there is a range named "newused" in yr workbook
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command Button

Since this code is behind a worksheet, any unqualified ranges will refer to the
worksheet that owns the code (and the button). And I bet that there isn't a
range named "NewUsed" on that sheet with the button.

You could use:

Sheets("Customer Profile").Select
sheets("customer profile").Range("newused") = 1

or (to save typing):

with Sheets("Customer Profile")
.Select
.Range("newused") = 1
end with

But it would be best to drop the select completely:
Sheets("Customer Profile").Range("newused") = 1



If the range is

John Excel wrote:

I have a coomand button that should select a sheet and change the value in a
cell.
The code I have used is as follows, but it generates an error.

Private Sub CommandButton2_Click()
Sheets("Customer Profile").Select
Range("newused") = 1
End Sub

Please advise weere I am going wrong.

Thanks in advance of a favourable reply.
John


--

Dave Peterson
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
Form Button vs Command Button Gizmo Excel Programming 2 April 8th 08 08:16 PM
Wanting to Create A Command Button Command bumper338 Excel Programming 3 May 7th 07 06:53 PM
VB's Command Button vs Form's Command Button Ronald Dodge Excel Programming 3 May 24th 06 02:23 PM
Command Button vs Form Button Bri[_3_] Excel Programming 2 February 3rd 06 08:18 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 08:29 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"