Start
'ログ出力1(引数) Public Sub LogInfo1(str As String) Call LogInfo2(Now, str) End Sub 'ログ出力2(引数) Public Sub LogInfo2(key As String, value As String) Call LogInfo3(key, value, ":") End Sub 'ログ出力3(引数) Public Sub LogInfo3(key As String, value As String, regx As String) Debug.Print key & regx & value End SubILogger
'Screen解除 Public Sub ScreenUpdateFalse() Application.ScreenUpdating = False End Sub 'Screenロック Public Sub ScreenUpdateTrue() Application.ScreenUpdating = True End Sub 'シート表示 Public Sub SheetShow(sht As Worksheet) If sht.Visible = xlSheetHidden Then sht.Visible = xlSheetVisible End If End Sub 'シート非表示 Public Sub SheetHide(sht As Worksheet) If sht.Visible = xlSheetVisible Then sht.Visible = xlSheetHide End If End Sub 'ブッククローズ(保存) Public Sub BookCloseforSaveTrue(wk As Workbook) wk.Close saveChanges:=True End Sub 'ブッククローズ(非保存) Public Sub BookCloseforSaveFalse(wk As Workbook) wk.Close saveChanges:=False End Sub '前行のフォーマットのコピー Public Sub CopyFormat(sht As Worksheet, targetRow As Long) sht.Rows(targetRow - 1).Select Selection.Copy sht.Rows(targetRow).Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False End Sub 'フォーカスの設定(A1) Public Sub SetFocusA1(sht As Worksheet) sht.Range("A1").Select sht.Range("A1").Activate End SubICommon
'頭文字の判断 Public Function StartsWith(str As String, startStr As String) As Boolean If Len(Trim(startStr)) > Len(Trim(str)) Or Len(Trim(startStr)) = Len(Trim(str)) Then StartsWith = False Else StartsWith = Left(str, Len(startStr)) = startStr End If End Function '指定数字の頭3ゼロの補足 Public Function FormatToLeft3Zero(number As Long) As String FormatToLeft3Zero = Format(number, "000") End Function '本文を「・」で区切 Public Function StrSpilt(str As String) As Variant Dim strs As Variant Dim newArr As Variant Dim ifor As Long strs = Split(str, "・") If IsEmpty(strs) Or UBound(strs) = 0 Then StrSpilt = Array() Exit Function End If ReDim newArr(UBound(strs) - 1) For ifor = 1 To UBound(strs) newArr(ifor - 1) = RemoveTrailingNewlinesRegex("・" & CStr(strs(ifor))) Next ifor StrSpilt = newArr End Function '指定列の最後行の番号取得 Public Function GetLastRow(colNum As String) As Integer GetLastRow = Common.GSheet.Cells(Common.GSheet.Rows.Count, colNum).End(xlUp).Row End Function '指定文字の含め判断 Public Function ContainsStr(mainString As String, substring As String) As Boolean ContainsStr = InStr(1, mainString, substring, vbTextCompare) > 0 End Function '改行文字の除く Public Function RemoveTrailingNewlinesRegex(str As String) As String Set regex = CreateObject("VBScript.RegExp") With regex .Global = True .Pattern = "\r?\n?$" End With If regex.test(str) Then str = regex.Replace(str, "") End If RemoveTrailingNewlinesRegex = str End Function '改行文字の除く Public Function RemoveTrailingNewlines(str As String) As String str = Replace(str, vbCrLf, "") str = Replace(str, Chr(13), "") str = Replace(str, Chr(10), "") RemoveTrailingNewlines = str End Function 'フィアル配列の取得 Public Function OpenWorkBooks() As Variant Dim xlsTmps As Variant xlsTmps = Application.GetOpenFilename("Excelファイル(*.csv;*.xls;*.xlsx),*.xlsx", , "タイトル", , True) If xlsTmps = True And Not xlsTmps Is Nothing Then OpenWorkBooks = xlsTmps Else OpenWorkBooks = Nothing Exit Function End If End Function '指定ブックのオーペン Public Function OpenWorkBook(obj As Object) As Workbook Dim xlsTmp As Workbook If IsObject(obj) Then Set xlsTmp = Application.Workbooks.Open(obj) Else Set xlsTmp = Nothing End If OpenWorkBook = xlsTmp Exit Function End FunctionIFunction
End
标签:Function,VBA,End,Sub,通常,str,関数,Public,String From: https://www.cnblogs.com/lnsylt/p/18382659