0

I want to hid some columns in my worksheets. I want to have them invisible for all external users. Thety cannot be aware, that the hidden column exist at all.

I found something, which can help me made them "Very hidden" likewise we can set for a whole sheets.

Unfortunately my approach doesn't work so far.

I have got a function, which should be right, but to be fair I don't know how to use it properly.

  Sub Overheadhidden()
  Columns("V:W").VeryHideColumn
  End Sub


  Function VeryHideColumn(myColumn As Range)
  'By M--, April 2017

   myColumn.Locked = True
   myColumn.Hidden = xlVeryHidden
   myColumn.FormulaHidden = True

   ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
    False, AllowFormattingCells:=True, AllowFormattingRows:=True, _
    AllowInsertingHyperlinks:=True, AllowSorting:=True, AllowFiltering:=True _
  , AllowUsingPivotTables:=True

  End Function

It comes from this solution:

Protecting and Hiding Columns same as "Very Hidden" Sheets

Is there ANY possible way to make the columns very hidden?

Geographos
  • 827
  • 2
  • 23
  • 57

1 Answers1

0

.VeryHideColumn() is not a method or a property. You need to call it as a function:

Sub Overheadhidden()

  Call VeryHideColumn(Columns("V:W"))

End Sub

I will also add that I would recommend this being a Sub rather than a Function simply because the general rule of thumb is to use Function when you want to return something. With your code you are simply giving it a task, so below is a bit better:

Sub VeryHideColumn(myColumn As Range)

   myColumn.Locked = True
   myColumn.Hidden = xlVeryHidden
   myColumn.FormulaHidden = True

   ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, _
       AllowFormattingCells:=True, AllowFormattingRows:=True, _
       AllowInsertingHyperlinks:=True, AllowSorting:=True, AllowFiltering:=True, _
       AllowUsingPivotTables:=True

End Sub
Dean
  • 2,326
  • 3
  • 13
  • 32