Sub CopyFormulasBasedOnCriteria() Dim wsSource As Worksheet Dim wsTemplate As Worksheet Dim lastRow As Long Dim i As Long Dim copyRow As Long Dim pasteRow As Long ' シートをセットアップ Set wsSource = ThisWorkbook.Sheets("Data") Set wsTemp…
Sub 判別して記入() Dim ws1 As Worksheet Dim ws2 As Worksheet Dim lastRow1 As Long Dim lastRow2 As Long Dim keyRange As Range Dim cell As Range Dim keyArray() As Variant Dim keyIndex As Long Dim labels() As String Dim labelIndex As Long Dim…
Sub コピー転記してから色付け() Dim wsSource As Worksheet Dim wsDestination As Worksheet Dim wsKeywords As Worksheet Dim lastRowSource As Long Dim lastRowKeywords As Long Dim i As Long Dim j As Long Dim keyword As String ' Sheet1をソース、S…
Sub UpdateDColumnWithRegex() Dim regex As Object Dim lastRow As Long Dim i As Long ' 正規表現オブジェクトを作成 Set regex = CreateObject("VBScript.RegExp") ' パターンを設定 regex.IgnoreCase = True regex.Global = True ' 最終行を取得 lastRow…
Sub 比較と記載1() ’Dictionaryにてremoveメソッド利用(ないものを削除パターン) Dim ws As Worksheet Dim lastRow1, lastRow2 As Long Dim aRange As Range, cRange As Range Dim aValue As Variant, cValue As Variant Dim compareColumnA As Range, compa…
Sub TransferData() Dim ws1 As Worksheet Dim ws2 As Worksheet Dim lastRow1 As Long Dim lastRow2 As Long Dim i As Long Dim j As Long Dim keyA As String Dim keyB As String Dim matchFound As Boolean ' Sheet1とSheet2を設定 Set ws1 = ThisWorkboo…
Sub 前日の日付を計算してセルに入力() Dim 検索日 As Date Dim 前日 As Date Dim 後日 As Date Dim フォーマット済み日付 As String Dim 休みの日 As Range ' セルA1に入力された日付を取得(ここではA1を例示しています) 検索日 = Range("A1").Value ' 休…
Sub 前日の日付を計算してセルに入力() Dim 検索日 As Date Dim 前日 As Date Dim フォーマット済み日付 As String Dim 休みの日 As Range ' セルA1に入力された日付を取得(ここではA1を例示しています) 検索日 = Range("A1").Value ' 休みの日をシート2の…
Sub ExtractWeekendAndHolidayDatesByMonth(yearToSearch As Integer, monthToSearch As Integer) Dim startDate As Date Dim endDate As Date Dim currentDate As Variant Dim ws As Worksheet Dim rowNum As Long Dim holidayDates As Variant Dim i As In…
Sub ExtractWeekendDates() Dim startDate As Date Dim endDate As Date Dim currentDate As Date Dim ws As Worksheet Dim rowNum As Long ' 新しいシートを作成します Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.C…
Sub ExtractWeekendAndHolidayDatesByYear(yearToSearch As Integer) Dim startDate As Date Dim endDate As Date Dim currentDate As Date Dim ws As Worksheet Dim rowNum As Long Dim holidayDates As Variant Dim i As Integer ' 新しいシートを作成しま…
Sub Sample() Range("B2:D5").EntireColumn.ClearEnd Sub
Sub Sample() Range("A:C").RemoveDuplicates(Array(1, 2, 3))End Sub
Sub UpdateDColumnWithRegex555() Dim regex As Object Dim lastRow As Long Dim i As Long '参照設定 Microsoft VBScript Regular Expressions 5.5 ' 正規表現オブジェクトを作成 Set regex = CreateObject("VBScript.RegExp") ' パターンを設定 regex.Igno…
Sub UpdateDColumn() Dim lastRow As Long Dim i As Long ' 最終行を取得 lastRow = Cells(Rows.Count, "C").End(xlUp).Row ' ループして条件に基づいてD列を更新 For i = 2 To lastRow If InStr(1, Cells(i, "C").Value, "AAA") > 0 And InStr(1, Cells(i, …
'//sakuracolor kuro-2.col ; テキストエディタ色設定 Ver3 [SakuraColor]C[BRC]=1,1,ffff84,202020,0C[CAR]=1,0,ff8080,3a3a3a,0C[CBK]=0,0,f2f8f8,0e1616,0C[CMT]=1,0,cc9b6a,202020,0C[CTL]=0,0,c6c6c6,202020,0C[CVL]=0,0,ffc184,3a3a3a,0C[DFA]=0,0,202…
Sub Main() Dim executionTime As Double executionTime = MeasureExecutionTime() MsgBox "計測完了" & vbLf & "実行時間は" & Format(executionTime, "0.000秒") & "でした"End SubFunction MeasureExecutionTime() As Double Dim startTime As Double sta…
Sub MessagePrompt() Dim response As VbMsgBoxResult ' メッセージボックスを表示し、ユーザーからの応答を取得します response = MsgBox("処理を続行しますか?", vbYesNo + vbQuestion, "確認") ' ユーザーがYesを選択した場合の処理 If response = vbYes…
'time計測Dim ST As DoubleST = Timer '処理時間の取得Debug.Print Timer - STMsgBox "取得が完了しました" & vbLf & "実行時間は" & Format(Timer - ST, "0.000秒") & "でした" '//-------------------- Debug.Print Now() & Right(Format(Timer, "0.00"), …
Sub ConvertDateFormatWithArray() Dim lastRow As Long Dim dateValues As Variant Dim convertedDates() As Variant Dim i As Long Dim yyyy As String Dim mm As String Dim dd As String ' 最終行を取得 lastRow = Cells(Rows.Count, "A").End(xlUp).Row…
@echo off set "WindowTitle=MyWindowTitle"set "Opacity=88" powershell.exe -Command "$signature='[DllImport(\"user32.dll\")]public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);';$winapi=Ad…
Sub CreateResultFile() ’セルC2が空白でない場合にはCSVファイルが作成し、かつセルC2が空白の場合にはテキストファイルが作成 Dim searchDate As String Dim fileName As String Dim filePath As String Dim fileContent As String Dim ws As Worksheet Di…
'//-------------------------------------------------------- Sub SaveAttachmentsToFolder() Dim olFolder As Outlook.MAPIFolder Dim olItem As Object Dim olAttachment As Outlook.Attachment Dim saveFolder As String ' 受信メールフォルダを指定し…
Sub SaveSearchResultAsPDF() Dim searchDate As String Dim fileName As String Dim filePath As String ' 検索日の取得 searchDate = Format(Date, "yyyymmdd") ' ファイル名の作成 fileName = "検索結果_" & searchDate & ".pdf" ' ファイルパスの作成(…
Sub CreateResultTextFile() Dim searchDate As String Dim fileName As String Dim filePath As String Dim fileContent As String ' 検索日の取得 searchDate = Format(Date, "yyyymmdd") ' ファイル名の作成 fileName = "対象なし_" & searchDate & ".txt…
■プログラム/スクリプト:VBSファイルパス Dim excelApp,macro file = WScript.Arguments(0)macro = WScript.Arguments(1) Set excelApp = CreateObject("Excel.Application") excelApp.Visible = False 'Excelを非表示にするexcelApp.DisplayAlerts = False…
起動画面(スプラッシュウィンドウ)を表示しない ”C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE” /e ---オプション---ブックのパス | ファイル名 Excel を起動し、指定されたファイルを開く。 excel.exe "c:\My Folder\book1.xlsx"/x …
バッチファイルのショットカットのリンク先の先頭に 「cmd.exe /c 」をつけて、適用 ※「cmd.exe /c 」のcの後ろには半角スペース
Sub 値のみ貼り付け() ' セルA1をコピー Worksheets("Sheet1").Range("A1").Copy ' セルB1に値のみを貼り付け Worksheets("Sheet2").Range("B1").PasteSpecial Paste:=xlPasteValues ' コピー状態を解除 Application.CutCopyMode = FalseEnd Sub
Sub SaveCSVWithDate() Dim savePath As String Dim fileName As String Dim currentDate As String ' 現在の日付を取得し、yyyymmdd形式にフォーマットする currentDate = Format(Date, "yyyymmdd") ' 保存先のパスを指定する場合 savePath = "C:\YourFolde…