+ Reply to Thread
Results 1 to 3 of 3

VBA exclude column within range

  1. #1
    Registered User
    Join Date
    11-19-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    43

    VBA exclude column within range

    Hi all,

    I have a piece of VBA code which hides and shows specific columns within a range based on the value of a particular cell.
    I have attached an example spreadsheet to demonstrate this, i.e. the variable cell being B2. If you type "A" into this cell, columns that have "A" in row 2 will only show. The same is true if you type "B".

    My range is currently looking at D2:H2 however I wish to omit column F from the range. I'm new to VBA hence not sure what the correct syntax is for omitting columns.

    The code i have used for Sheet 1 is as follows:

    Please Login or Register  to view this content.
    Thank you in advance, any feedback much appreciated.
    Attached Files Attached Files
    Last edited by syedmehdi; 03-06-2015 at 08:11 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA exclude column within range

    Try this.
    Please Login or Register  to view this content.
    The highlighted part checks the column isn't column 6 (F).
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-19-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    43

    Re: VBA exclude column within range

    That has worked perfectly. I was playing around with And but couldn't wok out where to put it (was trying to incorporate it into the Set headers line).

    Thanks for the solution and speedy response

+ 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. [SOLVED] Exclude Range from Macro
    By foobar42 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2013, 10:47 AM
  2. [SOLVED] How do I exclude data from 1 column using conditions from another column
    By Funky Gibbon in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 12-15-2013, 06:44 PM
  3. Replies: 8
    Last Post: 05-14-2012, 02:44 PM
  4. Replies: 3
    Last Post: 04-01-2012, 05:37 AM
  5. Replies: 8
    Last Post: 02-16-2011, 05:03 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