Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 28th, 2006, 04:18 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with Macro for Go to in WS

Good day all,

I need help in making a macro to allow me to "Go To" ceartain cells and set those cells to the current view using a combo box with the views predefined by name. Its for a worksheet thats really long and seperated by sections, this macro would help navigate the WS without having to scroll left for minutes... I know it sounds simple....i thought it was, But for some reason I cant figure it out!

Really, any help would be great!

Reply With Quote
  #2 (permalink)  
Old December 30th, 2006, 03:38 AM
Registered User
 
Join Date: Dec 2006
Location: , , USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Don't know how much help you need. I assume that you have already created named views. I created three views throughout the sheet and colored a range. On sheet2, I created a list of the view names in column A

Enter Excel VBA (alt-F11 or Tools|Macro|Visual Basic). Insert a form (Insert|UserForm). Design your form with a combobox and command button. Right click on UserForm1 (either on the form itself or in the VBAProject tree.

Add the following code to the for UserForm1
Code:
 Private Sub UserForm_Initialize()
    ComboBox1.ColumnCount = 1
    ComboBox1.RowSource = "Sheet2!$a$1:$a$3"
    ComboBox1.BoundColumn = 1
    ComboBox1.Value = "Red"   'this will set the top item in list to be displayed
End Sub



Private Sub CommandButton1_Click()
    ' this can be done more elegantly, but you can work on that
    ' later - it just illustrates the concept
    If ComboBox1.Value = "Red" Then
        ActiveWorkbook.CustomViews("Red").Show
    End If
    If ComboBox1.Value = "Yellow" Then
        ActiveWorkbook.CustomViews("Yellow").Show
    End If
    If ComboBox1.Value = "Green" Then
        ActiveWorkbook.CustomViews("Green").Show
    End If
End Sub
Right click on ThisWorkbook in the VBAProject tree and select view code and paste the following:
Code:
 Private Sub Workbook_Open()
    ' this will open the navigation form whenever the notebook is opened
    UserForm1.Show
End Sub
The form will stay open until the user closes it. An option that you may want to consider is to place a command button control in each section that will reopen the navigation menu if it is closed. Edit code for the button with:
Code:
Private Sub CommandButton1_Click()
    UserForm1.Show
End Sub
Reply With Quote
  #3 (permalink)  
Old December 31st, 2006, 02:11 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow!....

That was simple, Guy you have no idea how much you just helped me. About to months ago a got that report together for the bosses and from day one they have been heckling me for a "go to" type funcion. For now thats all I need, but I know I will need things in the future. This Macro thing is new to me. I got a book, but man is it hard to follow without help or formal training!

Any way, I wish i could some how pay you back man!

Thanks!

Reply With Quote
  #4 (permalink)  
Old December 31st, 2006, 03:44 AM
Registered User
 
Join Date: Dec 2006
Location: , , USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No problem - glad I could help. I actually learn more the more I try to figure out other people's challenges.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling to xlam macro from macro inside xlsb SteveB Excel VBA 0 June 30th, 2008 06:43 PM
How to INVOKE any WS on server by WS on client ? Abhinavnaresh ASP.NET 2.0 Professional 1 April 4th, 2008 01:09 PM
Query from a Repeating Table (via WS and C#) CSSmitty Infopath 2 September 10th, 2007 05:15 AM
Calling WS from javascript r_ganesh76 Javascript 5 December 8th, 2004 05:31 AM
Exposing WS Properties r_ganesh76 .NET Web Services 2 October 3rd, 2004 11:08 PM



All times are GMT -4. The time now is 12:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.