Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2006, 04:18 PM
Authorized User
 
Join Date: Dec 2006
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!

 
Old December 30th, 2006, 03:38 AM
Registered User
 
Join Date: Dec 2006
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
 
Old December 31st, 2006, 02:11 AM
Authorized User
 
Join Date: Dec 2006
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!

 
Old December 31st, 2006, 03:44 AM
Registered User
 
Join Date: Dec 2006
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.






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





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