Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

STL - Formerly Best Training Solutions Through Learning
TrustPilot
Excellent
Request Callback We will call you back
0207 987 3777 Call for assistance
Your Basket Basket is empty
excel vba

ResolvedVersion 2007

Cyrus has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Excel VBA

Hi, could anyone help me with VBA code for hiding columns in a workbook with 10 various worksheet?

For example, sheet 1, hide column G:G, K:K, & M:M
Sheet 2 hide column B:B, F:F, H:H

and the columns varies per each worksheet.

The purpose is to have a printable with with the remaining data.

Thanks
Cy

RE: Excel VBA

Hi Cyrus, thanks for your query. It's going to look a lot like this:

Range("G:G,K:K,M:M").Select
Selection.EntireColumn.Hidden = True

...for each sheet you need.

Hope this helps,

Anthony

Fri 2 Mar 2012: Automatically marked as resolved.

VBA tip:

Suspend DisplayAlerts in VBA

To stop Excel asking you things like "Do you want to delete this file...", use the following line of code at the beginning of the relevant VBA procedure:

Application.DisplayAlerts = False

At the end of the procedure make sure you use the following code to reactivate Display Alerts:

Application.DisplayAlerts = True

View all VBA hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.