+ Reply to Thread
Results 1 to 3 of 3

Button to display daily view, if data is blank hide the column

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-09-2008
    Location
    Middlesbrough, England
    MS-Off Ver
    2007
    Posts
    174

    Button to display daily view, if data is blank hide the column

    Hi,

    I have a dashboard which displays results at Monthly, Weekly & Daily level.

    To view the data you press a button and it hides the other views leaving the view you have requested.

    The issue i have is on the daily sometimes the data will be blank, eg. if its a Wednesday i wont have data for Wed,Thurs,Fri,Sat & Sun.

    Is there a way i can adapt my current code to hide the daily columns if the values are blank?
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Button to display daily view, if data is blank hide the column

    How about something like this
    Sub ViewDaily()
    Application.ScreenUpdating = False
    Columns("C:AL").Hidden = True
    Columns("V:AL").Hidden = False
    If IsNumeric(Range("V8").Value) = False Then Columns("V").Hidden = True
    If IsNumeric(Range("W8").Value) = False Then Columns("W").Hidden = True
    If IsNumeric(Range("X8").Value) = False Then Columns("X").Hidden = True
    If IsNumeric(Range("Y8").Value) = False Then Columns("Y").Hidden = True
    If IsNumeric(Range("Z8").Value) = False Then Columns("Z").Hidden = True
    If IsNumeric(Range("AA8").Value) = False Then Columns("AA").Hidden = True
    If IsNumeric(Range("AB8").Value) = False Then Columns("AB").Hidden = True
    
    If IsNumeric(Range("AE8").Value) = False Then Columns("AE").Hidden = True
    If IsNumeric(Range("AF8").Value) = False Then Columns("AF").Hidden = True
    If IsNumeric(Range("AG8").Value) = False Then Columns("AG").Hidden = True
    If IsNumeric(Range("AH8").Value) = False Then Columns("AH").Hidden = True
    If IsNumeric(Range("AI8").Value) = False Then Columns("AI").Hidden = True
    If IsNumeric(Range("AJ8").Value) = False Then Columns("AJ").Hidden = True
    If IsNumeric(Range("AK8").Value) = False Then Columns("AK").Hidden = True
    Application.ScreenUpdating = True
    End Sub
    Could have reduced the lines of code by creating a loop

  3. #3
    Forum Contributor
    Join Date
    09-09-2008
    Location
    Middlesbrough, England
    MS-Off Ver
    2007
    Posts
    174

    Re: Button to display daily view, if data is blank hide the column

    Excellent works a charm.

    Thankyou

+ 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. Hide blank rows button macro
    By cabinetguy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2016, 07:21 AM
  2. VBA coding to copy paste data on a daily basis to view the trend
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2013, 06:22 AM
  3. Replies: 0
    Last Post: 02-08-2010, 08:40 AM
  4. Hide button within userform if Combobox is blank
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2009, 11:43 AM
  5. Hide display command button based on conditions
    By mrdata in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-30-2007, 11:16 AM

Tags for this Thread

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