[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Move to a command button rather than a range

Folks,
My worksheets have command buttons. When I activate a worksheet I send the cursor to a cell location. Instead of a cell location how about to a command button, e.g., "cmdPrintSheet"
0
Frank Freese
Asked:
Frank Freese
  • 8
  • 6
  • 3
1 Solution
 
andrew_manCommented:
Sub P()

    Selection.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
End Sub
0
 
andrew_manCommented:
and link to a button or an image
0
 
Frank FreeseAuthor Commented:
Andrew,
Confused here?
What I am looking for is the ability to go to a command button when the sheet is activated. I did not see that in you suggestion or did not understand. I already have the code behind the command button.

In Access I can do this
cmdPrint.SetFocus
when a form opens.

In Excel I do this Range("A1")
I was thinking something along this line:

Sheet1.Controls("cmdPrint" ).Select

in the worksheet_activate section.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
andrew_manCommented:
Range("A1").selected
Selection.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

I suggest you should post your worksheet here!
0
 
Frank FreeseAuthor Commented:
OK...see attached
When this worksheet activates I would like it to have the command button
 "cmdDisplayResultsShaded" selected.
Thanks
MoveToCommandDisplayData.xlsm
0
 
Frank FreeseAuthor Commented:
Please used this file instead - the other has problems
Sorry about that
MoveToCommandDisplayData.xlsm
0
 
NorieVBA ExpertCommented:
Why do you want to select/goto the command button?
0
 
andrew_manCommented:
Asker,

What is the version of your excel?
0
 
Frank FreeseAuthor Commented:
Excel 2007 version
The reason is I'd like to set a default for the user that is not a cell.
0
 
NorieVBA ExpertCommented:
Not sure what you mean but you can select the button with this.
Shapes("cmdDisplayResultsShaded").Select

Open in new window

Don't know if it'll make the button 'default'.
0
 
Frank FreeseAuthor Commented:
imnorie,
Since the worksheet will be protected I had to check "Edit objects" before I protected the worksheet. When I did that your code worked.
0
 
Frank FreeseAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for fh_freese's comment #a39698860

for the following reason:

Folks,
I accepted Imnorie's code with this only change. Since the worksheet will be protected I had to check "Edit objects" before I protected the worksheet. When I did that your code worked.
Thanks to all -
0
 
andrew_manCommented:
Do you think no any solutions?
0
 
Frank FreeseAuthor Commented:
Did not intend to award myself points but instead Imnorie.
0
 
Frank FreeseAuthor Commented:
thanks
sorry for the mix up
0
 
andrew_manCommented:
Good!
0
 
NorieVBA ExpertCommented:
fh_freeze

Glad it worked.

Wasn't sure about protection as the worksheet in the attached workbook didn't appear to be protected.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 8
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now