VBA code to enable macros

%3CLINGO-SUB%20id%3D%22lingo-sub-1501085%22%20slang%3D%22en-US%22%3EVBA%20code%20to%20enable%20macros%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1501085%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20mentioned%20the%20below%20VBA%20program%20to%20open%20a%20file%2C%20unhide%20a%20tab%20and%20then%20clear%20the%20contents%20from%20a%20particular%20cell.%20but%20since%20the%20option%20to%20allow%20macros%20is%20not%20enabled%20by%20default%20and%20I%20cannot%20change%20the%20settings%20due%20to%20company%20work%20settings.%20Also%20after%20that%20the%20excel%20file%20which%20needs%20to%20be%20opened%20asks%20if%20we%20need%20to%20update%20links%20or%20not.%20Is%20there%20a%20code%20which%20can%20help%20me%20to%20resolve%20the%20attached%20screenshots.%26nbsp%3B%20Due%20to%20this%20I%20am%20getting%20error%20message%20at%20the%20line%26nbsp%3BWorksheets(%22All%20Data%22).Visible%20%3D%20xlSheetVisible%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20first()%3CBR%20%2F%3EDim%20Mainfile%20As%20String%3CBR%20%2F%3EMainfile%20%3D%20Application.GetOpenFilename%3CBR%20%2F%3EWorksheets(%22All%20Data%22).Visible%20%3D%20xlSheetVisible%3CBR%20%2F%3EDim%20CelPos1%20As%20Integer%3CBR%20%2F%3ERange(%22CelPos1%22).Value%20%3D%20Range(%22A3%22).End(xlDown).Row%3CBR%20%2F%3ERange(%22A3%3ABOCelPOs1%22).ClearContents%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1501085%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Frequent Visitor

I have mentioned the below VBA program to open a file, unhide a tab and then clear the contents from a particular cell. but since the option to allow macros is not enabled by default and I cannot change the settings due to company work settings. Also after that the excel file which needs to be opened asks if we need to update links or not. Is there a code which can help me to resolve the attached screenshots.  Due to this I am getting error message at the line Worksheets("All Data").Visible = xlSheetVisible

 

Sub first()
Dim Mainfile As String
Mainfile = Application.GetOpenFilename
Worksheets("All Data").Visible = xlSheetVisible
Dim CelPos1 As Integer
Range("CelPos1").Value = Range("A3").End(xlDown).Row
Range("A3:BOCelPOs1").ClearContents

0 Replies