+ Reply to Thread
Results 1 to 8 of 8

Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2014
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    Below is the VBA Code I use for my sheet. I have feilds formulated between $A$18:$W$2500, and if they return a blank value or "" then it automatically hides the row. The VBA code was put in well after the sheet was created and the original print_area for the sheet is A17:W150. The Macro only looks at column A for the blanks and from what I can tell has nothing to do with the print_area. But, if I change the print_Area to what I want the Macro quits working properly. When I change print_area (even if I change it to the exact same thing), when I hit the Macro button it just runs indefinetly with no end. If I hit ESC twice and hit end Macro then the Macro stops running and produces the correct results. So in essence, the button (Macro) is still working, it just never stops running once the Print_Area is changed. I need the print area to be A6:W2500 so that it captures the entire return of Non-Hidden fields. Any Ideas why it would be doing this?


    Sub L12OVER500_CommandButton1_Click()

    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

    Dim rCell As Range

    For Each rCell In Range("A18:A2500")
    If rCell = "" Then
    rCell.EntireRow.Hidden = True
    Else
    rCell.EntireRow.Hidden = False
    End If
    Next rCell

    Application.EnableEvents = True

    End Sub

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    Hi Supe,

    Try this and let me know whether that was what you wanted:

    Sub L12OVER500_CommandButton1_Click()
    
    With Application: .EnableEvents = False: .ScreenUpdating = False: End With
            Dim r As Long, c As Long: ActiveSheet.Rows.Hidden = False
     
                For r = 18 To 2500: For c = 1 To 24
                If Val(Cells(r, c)) = 0 Then
        Cells(r, c).EntireRow.Hidden = True: GoTo GetNext: End If: Next c
    GetNext:    Next r
     Application.EnableEvents = True:Application.ScreenUpdating = True
     End Sub
    Last edited by xladept; 02-19-2014 at 10:16 PM. Reason: .ScreenUpdating = False/Arkadi
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    It probably has no bearing on your problem, but you are missing Application.screenupdating = true
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    02-04-2014
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    Nope, just made the screen flash.. I had is set to FALSE

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    I just meant at the very end of the sub, but I doubt that's your issue
    issue

  6. #6
    Registered User
    Join Date
    02-04-2014
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    Yeah I tried it at the beginning and the end and it too works as long as I dont change the Print_Area. As soon as I change the print_area it goes bonkers and runs indefinetly. Its almost like change the print area is affecting the "End If" function and its not making it past that point. When it runs indefinetly and I try to debug it is highlight the "End If" Function.

    Quote Originally Posted by Arkadi View Post
    I just meant at the very end of the sub, but I doubt that's your issue
    issue

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    What about xladept's code? Same?
    Another suggestion, only try to hide the row if not already hidden? I.e. if.. Hidden = false then... Hidden = true? Sorry poor typing on cell
    And/or if rCell.value = ""
    Last edited by Arkadi; 02-19-2014 at 10:14 PM.

  8. #8
    Registered User
    Join Date
    02-04-2014
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Removing Blank Feilds with Button (Macro) (PRINT AREA ISSUES) Help!!

    I think I got it and I feel dumb! I would use the xladept's code but I have multiple Macros and button functions and I dont want them all trying to run. The issue is my wonderful work computer believe it or not. It only has 2gb of RAM and I have used this database so much that when I made the change the RAM was full so it was locking up because it was different. I am just used to working with a little more RAM so once I cleared my RAM it began to run. Still slow, but I believe it will speed up after being used a few times. Sry to waste your time and I appreciate the help.

    Quote Originally Posted by Arkadi View Post
    What about xladept's code? Same?
    Another suggestion, only try to hide the row if not already hidden? I.e. if.. Hidden = false then... Hidden = true? Sorry poor typing on cell
    And/or if rCell.value = ""

+ 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. Variable print area macro issues
    By fourmurphys in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2013, 01:13 PM
  2. Set Print Area Macro - Exclude Blank Rows
    By shudder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2009, 10:31 PM
  3. Excel 2007 : Print Area Issues
    By jade12378 in forum Excel General
    Replies: 2
    Last Post: 05-20-2009, 05:07 AM
  4. Button for Set Print Area
    By Paul1975 in forum Excel General
    Replies: 3
    Last Post: 05-09-2008, 05:57 AM
  5. [SOLVED] Edit PivotTable by removing Sales Button from ROW area?
    By eholt1941 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-13-2006, 09:45 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