+ Reply to Thread
Results 1 to 5 of 5

Trying to get tabs working

Hybrid View

  1. #1
    Registered User
    Join Date
    01-17-2018
    Location
    AUS
    MS-Off Ver
    2016 pro
    Posts
    12

    Trying to get tabs working

    Hi All
    I a noob with this VBA I am trying to do somthing the same as Excel Freelance, on you tube and i have hit a bit of a snag
    On the proceure page i am trying to have each tab open a diffrent page and its not working. I have followed the same as what he has been doing

    Sub SwitchHorizontalTabs()
    Dim SelCol As Long
    Dim FirstRow As Long
    With Sheet1
    SelCol = .Range("B2").Value
    .Range("5:84").EntireRow.Hidden = True
    FirstRow = 5 + ((SelCol - 5) * 20)
    .Range(FirstRow & ":" & FirstRow + 19).EntireRow.Hidden = False
    End With
    End Sub
    
    
    Sub SwitchVerticalTabs()
    Dim SelRow As Long
    Dim FirstRow As Long
    SelRow = Right(AvtiveCel.Row, 1) - 5
    With Sheet1
    .Range("46:144").EntireRow.Hidden = True
    FirstRow = 46 + ((SelRow - 1) * 20)
    .Range(FirstRow & ":" & FirstRow + 19).EntireRow.Hidden = False
    .Range("B3").Value = SelRow + FirstRow
    .Range("F2").Select
    End With
    
    End Sub
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("E4:H4")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
      Range("B2").Value = Target.Column
      Range("F2").Select
      SwitchHorizontalTabs
    End If
    If Not Intersect(Target, Range("E46:E144")) Is Nothing Then
       If Target.Value = Empty Or Target.Value = "Select Options" Then Exit Sub
       SwitchVerticalTabs
      End With
    End Sub
    The top line on the second code is highlighted yellow as well and i can't get it to work
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Trying to get tabs working

    couple of problems.

    First the final line in the Worksheet_SelectionChange event is 'End With' rather than 'End if'.

    That will allow the code to proceed to this line, which I think the error is the missing spelling of ActiveCell

    SelRow = Right(AvtiveCel.Row, 1) - 5   ' change AvtiveCel to ActiveCell
    Perhaps you should ask Excel Freelance to provide 'you tube' information on the usefulness of Option Explicit
    Cheers
    Andy
    www.andypope.info

  3. #3
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    422

    Re: Trying to get tabs working

    You need to replace the 'End With' at the bottom with an 'End If'.

  4. #4
    Registered User
    Join Date
    01-17-2018
    Location
    AUS
    MS-Off Ver
    2016 pro
    Posts
    12

    Re: Trying to get tabs working

    Thank you Andy and mgs73 for your help that part worked

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,575

    Re: Trying to get tabs working

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. IF(AND not working across multiple tabs
    By Stuepef in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2017, 09:48 PM
  2. HELP working out VLOOK formula i need to use across tabs
    By Tafflisa in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-26-2016, 06:09 PM
  3. VLOOKUP -- multiple Tabs - not working
    By chacamasur in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-24-2014, 05:30 PM
  4. Working with tabs and calculating across multiple ones
    By cgsweger in forum Excel General
    Replies: 1
    Last Post: 01-06-2014, 03:19 PM
  5. is there a formula for this (when working with 2 tabs)
    By wonderingwoman in forum Excel General
    Replies: 8
    Last Post: 03-30-2012, 10:05 AM
  6. Working with Multiple Tabs/Windows
    By whonoh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-26-2007, 09:51 AM
  7. Links in Tabs not working
    By michael.woosley in forum Excel General
    Replies: 1
    Last Post: 10-11-2006, 05:22 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1