Solved

hide certain rows in Excel Macro

Posted on 2014-10-30
2
290 Views
Last Modified: 2014-10-30
Hi experts,

I have a task in Excel and think it can be accomplished by a macro or two macros, written by VBA, etc. I do not know any new development of VB, such as VB script, or VB.net, etc.

The main tasks are two steps.
1. to hide all rows that with "X" in cell A. For example if A2=X, hide row 2, A34=X, hide row 34.
2. after the hiding, set the print preview for the whole area with non-empty cells.

I image it can be done with a macro and with a click of button to change the normal view to the the print preview mode.

After this is done, we can have a separate button to back to normal view. Or we can add something to the original button for switched views between normal and print preview. It does not matter whether it is two buttons or one button to have it accomplished.

Thanks,
RDB
0
Comment
Question by:ResourcefulDB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
ID: 40413464
Hi,

pls try

Sub Macro()
For Each cel In Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    If cel = "X" Then
        cel.EntireRow.Hidden = True
    Else
        cel.EntireRow.Hidden = False
    End If
Next
ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address
End Sub

Open in new window

Regards
0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 250 total points
ID: 40413585
No need for VBA.

You can just put an Auto Filter on Col A to Hide rows containing X.

Then there is standard Print Preview and Normal View buttons on the View Ribbon.

Thanks
Rob H
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question