Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Form Button vs Command Button | Excel Programming | |||
Wanting to Create A Command Button Command | Excel Programming | |||
VB's Command Button vs Form's Command Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming | |||
Command Button vs Form Button | Excel Programming |