Results 1 to 8 of 8

Column number reference using cell reference

Threaded View

  1. #1
    Registered User
    Join Date
    06-02-2015
    Location
    B
    MS-Off Ver
    2013
    Posts
    5

    Column number reference using cell reference

    Hi all,

    I have created a basic macro which hides columns before and after a specified range. I have calculated the column numbers from a user specified date in excel and want to use these cell references in my VBA code to hide the columns.

    For example:

    Cell B9's formular tells me the users date starts at column 37.
    Cell B10's formular tells me the users date ends at column 42.

    Becuase these dates change I need to reference cells B9 and B10 and not the column numbers 37 and 42.

    So I want to hide colomns 4:B9 and B10:55.

    My code keeps failing with error "type mismatch".



    Sub Hide_ProjectA()
    '
    ' Hide_ProjectA Macro
    ' Hides columns outside a specified project date range
    
    'Unhide all columns
    Columns("D:BC").Hidden = False  'Unhide all week Columns
    
    'Hides all columns before project A
    ActiveSheet.Columns("4:B9").EntireColumn.Hidden = True
    
    'Hides all columns after project A
    Columns("B10:55").Hidden = True
    
    
    Application.ScreenUpdating = True
    
    
    End Sub
    Any help would be great!
    Last edited by FDibbins; 06-02-2015 at 10:54 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to reference cell value from column number and row number
    By jed38 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2015, 07:37 PM
  2. Replies: 1
    Last Post: 02-11-2015, 01:56 PM
  3. [SOLVED] VLOOKUP to reference cell, not column number
    By Prodschdler in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-18-2013, 02:27 PM
  4. Go to a cell in column, based on a reference number
    By Joshua@work in forum Excel General
    Replies: 5
    Last Post: 06-30-2010, 07:28 PM
  5. Replies: 1
    Last Post: 02-03-2006, 12:00 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