macro which hide part

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

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Macro which will hide the part of the sheet for any particular s

Macro which will hide the part of the sheet for any particular s

resolvedResolved · Urgent Priority · Version 365

Sanjay has attended:
Excel VBA Introduction course
Excel VBA Intermediate course

Macro which will hide the part of the sheet for any particular s

Hi ,

I have a sheet where I have to select one option out of the below mention 3 options.

Uk
VGE
IN

I need to design a macro in that way where If I select VGE then a area of the sheet should be hide (Because that area is for UK only).

please let me know if you need any more information from me.

Thanks
Sanjay

RE: Macro which will hide the part of the sheet for any particul

Hi Sanjay,

Thank you for the forum question. You can only hide whole rows or whole columns in Excel, but a walk around it can be move the data to another destination and then clear them.

I know you are not interested in adding more worksheets to the workbook. In my code below I use a range starting from A4000. If you are not using this range for anything you can keep the code as it is. You will have to amend something.

In my code I had the dropdown list in B9. You need to change this to the cell you use.You will also have to amend the following lines to fit you data:
Sh.Range("f6:l13").Copy
Sh.Range("f6").Select
Sh.Range("f6:l13").Clear






Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application.ScreenUpdating = False
Set Sh = Sheets("Test")
If Not Application.Intersect(Target, Sh.Range("b9")) Is Nothing Then

If Range("B9").Value = "VGE" Then


Sh.Range("f6:l13").Copy
Sh.Range("a4000").Select
ActiveSheet.Paste
Sh.Range("f6:l13").Clear
Sh.Range("a1").Select
Else
If Range("A4000").Value = "" Then
Exit Sub
Else
Sh.Range("A4000").CurrentRegion.Copy
Sh.Range("f6").Select
ActiveSheet.Paste
Sh.Range("A4000").CurrentRegion.Clear
End If


End If


End If
Application.ScreenUpdating = True
End Sub



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Macro which will hide the part of the sheet for any particul

Hi Janes,

Thanks for getting me back.

I tried the same code but not working for me (might be i have done something wrong).

Is there any way I can send my test sheet to you .

Thanks
Sanjay

RE: Macro which will hide the part of the sheet for any particul

Hi Sanjay,

You can send it to info@stl-training.co.uk



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Macro which will hide the part of the sheet for any particul

thanks.

send a mail on the same with subject ''Test file

RE: Macro which will hide the part of the sheet for any particul

Hi Sanjay,

I have not received any file.

Please try to send it to:

jens@stl-training.co.uk


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Macro which will hide the part of the sheet for any particul

sent..

RE: Macro which will hide the part of the sheet for any particul

Hi Sanjay,

The code is in the ThisWorkbook private module. Open the visual basic editor. Double click ThisWorkbook in the Project Explorer (the top left side of the Visual Basic editor).



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Macro which will hide the part of the sheet for any particul

Hi Sanjay,

The code must be in the workbook's private module (double click ThisWorkbook in the visual basic editor)

Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Tue 5 Sep 2017: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Auto-insert the current time

In Microsoft Excel, to enter the current time into a cell, hold CTRL+SHIFT and press SEMICOLON.

View all Excel hints and tips


Server loaded in 0.11 secs.