Solved

Move to a command button rather than a range

Posted on 2013-12-05
17
224 Views
Last Modified: 2013-12-05
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
Comment
Question by:Frank Freese
  • 8
  • 6
  • 3
17 Comments
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
Sub P()

    Selection.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
End Sub
0
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
and link to a button or an image
0
 

Author Comment

by:Frank Freese
Comment Utility
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
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
Range("A1").selected
Selection.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

I suggest you should post your worksheet here!
0
 

Author Comment

by:Frank Freese
Comment Utility
OK...see attached
When this worksheet activates I would like it to have the command button
 "cmdDisplayResultsShaded" selected.
Thanks
MoveToCommandDisplayData.xlsm
0
 

Author Comment

by:Frank Freese
Comment Utility
Please used this file instead - the other has problems
Sorry about that
MoveToCommandDisplayData.xlsm
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Why do you want to select/goto the command button?
0
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
Asker,

What is the version of your excel?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Frank Freese
Comment Utility
Excel 2007 version
The reason is I'd like to set a default for the user that is not a cell.
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
Comment Utility
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
 

Author Comment

by:Frank Freese
Comment Utility
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
 

Author Comment

by:Frank Freese
Comment Utility
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
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
Do you think no any solutions?
0
 

Author Comment

by:Frank Freese
Comment Utility
Did not intend to award myself points but instead Imnorie.
0
 

Author Closing Comment

by:Frank Freese
Comment Utility
thanks
sorry for the mix up
0
 
LVL 4

Expert Comment

by:andrew_man
Comment Utility
Good!
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now