Results 1 to 4 of 4

Thread: VB script in Excel using Forms

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    4

    Question VB script in Excel using Forms

    Ok, it's been a long time since my college classes on vb scripting, so I'm hoping for a point in the right direction.

    In an Excel spreadsheet, on one tab, I have a list of about 200 servers and how they appear on racks in our datacenter. It's a rough visual map of the center. On another tab I have all the information regarding each server.

    Is there a way to click on a server name, or a button next to it if that's what I have to use, and in so doing have a text box populate with information from the second tab regarding that server? I know how to do a simple vlookup to find that information, but how do I script it so that by clicking in the cell, or a button, it populates a text box with that info?

    Sorry if this is a bit confusing, or even if it's a bit too much for someone as rusty as myself. But any help is MUCH MUCH MUCH appreciated.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB script in Excel using Forms

    Welcome to the Forums.

    Two options,

    1.) Create hyperlinks on the server names to link to the second sheet.

    2.) Use VBA to populate a textbox on your sheet1 with the specs from sheet2.

    I think #1 is easier.

    VB Code:
    1. 'Behind Sheet1
    2. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    3.     'Only act on cells in the first column "A"
    4.     If ActiveCell.Column = 1 Then
    5.         If ActiveCell.Hyperlinks.Count = 0 Then
    6.             ActiveCell.Hyperlinks.Add ActiveCell, Sheet2.Cells(ActiveCell.Row, 1)
    7.         End If
    8.         'ActiveCell.Hyperlinks.Item(1).Follow False 'Isnt working on my system?
    9.         Sheet2.Activate
    10.         Sheet2.Cells(ActiveCell.Row, 1).Activate
    11.     End If
    12. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    4

    Thumbs up Re: VB script in Excel using Forms

    RobDog, you rock! Your code didn't work perfectly (never does, does it?), but I think it got me going in the right direction. Thanks man!

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB script in Excel using Forms

    Thanks! You know we all have an "off-day" once in a while.

    If this ends up not working out good enough, just drop a thread in here and I will try to help out more.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width