{"id":14070829,"url":"https://github.com/santosrai/VBA-For-Everyone","last_synced_at":"2025-07-30T08:32:53.453Z","repository":{"id":116779900,"uuid":"215726032","full_name":"santosrai/VBA-For-Everyone","owner":"santosrai","description":"This is utility module with lots of reuseable functions for VBA","archived":false,"fork":false,"pushed_at":"2021-03-18T02:22:56.000Z","size":52,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-04T12:41:27.536Z","etag":null,"topics":["reuseable-functions","vba","vba-excel"],"latest_commit_sha":null,"homepage":"","language":"VBA","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santosrai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-17T07:07:50.000Z","updated_at":"2023-06-04T04:38:35.000Z","dependencies_parsed_at":"2024-02-22T10:30:14.921Z","dependency_job_id":null,"html_url":"https://github.com/santosrai/VBA-For-Everyone","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/santosrai/VBA-For-Everyone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santosrai%2FVBA-For-Everyone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santosrai%2FVBA-For-Everyone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santosrai%2FVBA-For-Everyone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santosrai%2FVBA-For-Everyone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santosrai","download_url":"https://codeload.github.com/santosrai/VBA-For-Everyone/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santosrai%2FVBA-For-Everyone/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267835665,"owners_count":24151824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["reuseable-functions","vba","vba-excel"],"created_at":"2024-08-13T07:08:07.163Z","updated_at":"2025-07-30T08:32:53.169Z","avatar_url":"https://github.com/santosrai.png","language":"VBA","funding_links":[],"categories":["VBA"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003e VBA for Everyone \u003c/h1\u003e\n\n\u003csub\u003eAuthor: Santosh Rai\n\u003csmall\u003e January, 2018\u003c/small\u003e\n\u003c/sub\u003e\n\n\u003c/div\u003e\n\n- [Introduction](#introduction)\n- [Requirements](#requirements)\n- [Setup](#setup)\n- [Variables](#variables)\n- [Comments](#comments)\n- [Coding Style](#codingstyle)\n- [Data types](#data-types)\n- [Checking Data Type and casting](#data-types-casting)\n- [Conditionals](#conditionals)\n  - [if](#if)\n  - [if else](#if-else)\n  - [if else if else](#if-else-if-else)\n  - [switch](#switch)\n  - [Ternary Operators](#ternary-operators)\n  - [While loop](#while-loop)\n  - [Do while loop](#do-while-loop)\n- [Arrays](#arrays)\n- [Functions](#functions)\n- [Classes](#classes)\n  - [Defining a classes](#defining-a-classes)\n  - [Class Instantiation](#class-instantiation)\n  - [Class Constructor](#class-constructor)\n  - [Default values with constructor](#default-values-with-constructor)\n  - [Class methods](#class-methods)\n  - [Properties with initial value](#properties-with-initial-value)\n  - [getter](#getter)\n  - [setter](#setter)\n  - [Static method](#static-method)\n  - [CommonVBA.Utility](#CommonVBA-Utility)\n\n\n## Introduction\n\u003c!-- TODO: add --\u003e\n## Requirments\n\u003c!-- TODO: add --\u003e\n## Setup\n\u003c!-- TODO: add --\u003e\n## CodingStyle\n\u003c!-- TODO: add --\u003e\n```vb\n'/**\n' * @Purpose:  Get Corresponding sheet\n' * @Param  :  {Workbook} Book\n'            {String}   sheetname　\n' * @Return :　{Worksheet} sheet\n' */\n```\n\n## CommonVBA-Utility\nThis is utility module with lots of reuseable functions for VBA\n* Function to get worksheet object\n\n```vb\n'/**\n' * @Purpose:  Get Corresponding sheet\n' * @Param  :  {Workbook} Book\n'            {String}   sheetname　\n' * @Return :　Worksheet\n' */\nPublic Function GetSheet(ByVal Book As Workbook, ByVal SheetName As String) As Worksheet\n    Dim sheet As Object\n    For Each sheet In Book.Worksheets\n        If sheet.Name = SheetName Then\n            Set GetSheet = sheet\n            Exit Function\n        End If\n    Next\n    Set GetSheet = Nothing\n    \nEnd Function\n```\n* Function to get last row or column count number\n```vb\n'/**\n' * @Purpose:  Return the Last Row Or Column Number\n' * @Param  :  {Workbook} Workbook\n'            {String}   RowColumn\n' * @Return :　{Long} RowColumn\n' */\nPublic Function GetLastRowColumn(ws As Worksheet, RowColumn As String) As Long\n    Dim LastRowColumn As Long\n    Select Case LCase(Left(RowColumn, 1)) 'If they put in 'row' or column instead of 'r' or 'c'.\n        Case \"c\"\n            LastRowColumn = ws.Cells.Find(\"*\", LookIn:=xlFormulas, SearchOrder:=xlByColumns, _\n            SearchDirection:=xlPrevious).Column\n        Case \"r\"\n            LastRowColumn = ws.Cells.Find(\"*\", LookIn:=xlFormulas, SearchOrder:=xlByRows, _\n            SearchDirection:=xlPrevious).Row\n        Case Else\n            LastRowColumn = 1\n        End Select\n    'Return\n    GetLastRowColumn = LastRowColumn\nEnd Function\n```\n\n* Function to get workbook\n```vb\n'/**\n' * @Purpose:  Get Corresponding workbook\n' * @Param  :  {String}    Name of workbook\n' * @Return :　{Workbook}  Corresponding workbook if it find the workbook otherwise Nothing\n' */\nPublic Function GetWorkbook(ByVal WorkBookName As String) As Workbook\n    Dim EachWorkbook As Object\n    \n    If Not Trim(WorkBookName) = vbNullString Then\n        For Each EachWorkbook In Excel.Workbooks\n            If EachWorkbook.Name = WorkBookName Then\n                  Set GetWorkbook = EachWorkbook\n                  Exit Function\n            End If\n        Next EachWorkbook\n    End If\n    \n    Set GetWorkbook = Nothing\n    \nEnd Function \n```\n\n* Function to find dynamic array is empty or not\n([source from cpearson](http://www.cpearson.com/excel/IsArrayAllocated.aspx))\n```vb\n'/**\n' * @Purpose:  Find out dynamci array allocated or not\n' * @Param  :  {Varaint}  Arr\n' * @Return :　{Boolean}  Return True if Arr is a valid and allocted array\n' */\nFunction IsArrayAllocated(Arr As Variant) As Boolean\n        On Error Resume Next\n        IsArrayAllocated = IsArray(Arr) And _\n                           Not IsError(LBound(Arr, 1)) And _\n                           LBound(Arr, 1) \u003c= UBound(Arr, 1)\nEnd Function                           \n```\n\n* Function to check whether given file exist or not\n```vb\n'/**\n' * @Purpose:  Check whether given file exist or not\n' * @Param  :  {String} FilePath\n' * @Return :　{Boolean} True if successful\n' */\nPublic Function FileExist(FilePath As String) As Boolean\nDim GetFile As String\nDim FileExistResult As Boolean\n    \n     GetFile = Dir(FilePath)\n    \n     If GetFile \u003c\u003e \"\" Then\n            FileExistResult = True\n     End If\n    \n    'return\n    FileExist = FileExistResult\n    \nEnd Function\n```\n\n* Function to check whether input is valid or not\n\n```vb\n'/**\n' * @Purpose:  Check whether TextBox is valid or not\n' * @Param  :  {String} ctrlName *Optional\n' * @Return :　Nothing\n' */\nPublic Sub ValidateForm(Optional ctrlName As String)\nDim ctrl As Object\nDim ControlName As String\n\n    For Each ctrl In Me.Controls\n        If TypeName(ctrl) = \"TextBox\" Then\n            ControlName = IIf(ctrlName \u003c\u003e \"\", ctrlName, ctrl.ControlName)\n            If IsNull(ctrl.Value) Then\n                ctrl.SetFocus\n                MsgBox ControlName \u0026 \"に入力してから実行してください。\"\n                End\n            End If\n        End If\n    Next ctrl\nEnd Sub\n\n```\n\n* Function to find whether Userform is existed or not\n\n```vb\n'/**\n' * @Purpose:  Find whether Userform is existed or not\n' * @Param  :  {String} userform name\n' * @Return :　 {Boolean} True if userform is exist\n' * @References: 'http://custom-designed-databases.com/wordpress/2011/ms-access-vba-does-form-exist-function/\n' */\n\nFunction isFormLoaded(formName As String) As Boolean\n\nDim retVal As Boolean\n\nOn Error GoTo ErrHandler\n\nretVal = CurrentProject.AllForms.Item(formName).IsLoaded\nretVal = (CurrentProject.AllForms.Item(formName).CurrentView = acCurViewDatasheet Or CurrentProject.AllForms.Item(formName).CurrentView = acCurViewFormBrowse)\n\nisFormLoaded = retVal\n\nGoTo ExitRoutine\n\nErrHandler:\n\nIf Err.Number = 2467 Then\n  retVal = False\n'  Debug.Print “Form is not loaded or does not exist”\nEnd If\n\nExitRoutine:\n\nisFormLoaded = retVal\n\nEnd Function\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantosrai%2FVBA-For-Everyone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantosrai%2FVBA-For-Everyone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantosrai%2FVBA-For-Everyone/lists"}