+ Reply to Thread
Results 1 to 10 of 10

VBA for Hiding/Unhiding columns

  1. #1
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    VBA for Hiding/Unhiding columns

    Hi, I am using the code below in order to hide/unhide columns and so update a chart that is sourcing the data from said columns. It works OK on my first worksheet but when I've copied it to the second and changed the Range name it doesn't work on the second. Can anyone help?

    Thanks in advance,

    A.

    Please Login or Register  to view this content.
    Last edited by Theangelp; 11-25-2016 at 03:48 AM. Reason: Change title

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,444

    Re: VBA Assistance

    Try specifying the Sheet by using "ActiveSheet" ?

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: VBA Assistance

    Hello Logit,

    In VBA if a Range object is not prefaced with the name of the Worksheet it is on, the assumption is the ActiveSheet.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: VBA Assistance

    Theangelp, your code worked fine for me. Do you know line that stops your code? Did you try step-by-step test?
    My guess - something wrong with named range

  5. #5
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Re: VBA Assistance

    Thanks all.

    Kasan - it's not stopping; it's not even starting!. On the initial worksheet when I select the data I want shown on the chart (from a drop-down) the code works fine by hiding/unhiding the relevant column, however when I do the same thing on the second worksheet nothing happens (unless I go into the code and hit Run).

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: VBA Assistance

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Never use Merged Cells in Excel

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: VBA for Hiding/Unhiding columns

    You said that you've change range name and you refering to Range("FIIndexRange") in the code.

    P.S. You don't need to give me reputation for reminding on rules. It won't make me more tolerant

  8. #8
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Re: VBA for Hiding/Unhiding columns

    Thanks zbor.

    Yes, the named range on the first worksheet has a different name.

  9. #9
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: VBA Assistance

    Theangelp it's not even starting!. nothing happens (unless I go into the code and hit Run).
    Just to be sure - do you have Worksheet_Calculate() code in each sheet`s code or just in one sheet code?

  10. #10
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Re: VBA Assistance

    I have it in each sheet's code.

+ 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 Assistance
    By djchaney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2014, 03:14 PM
  2. vba assistance req
    By Thinking About Sport in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-11-2010, 09:22 PM
  3. Need some assistance
    By CO1966 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2008, 07:41 PM
  4. Need Assistance With This
    By alexm999 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2007, 05:46 PM
  5. Need some assistance
    By mjman15 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-10-2005, 06:44 PM
  6. [SOLVED] Assistance please?
    By http:// in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  7. Assistance please?
    By http:// in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-06-2005, 04:05 PM

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