2024-03-01から1ヶ月間の記事一覧
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…
Sub 転記() Dim LastRow As Long Dim i As Long ' Sheet1の最終行を取得 LastRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row ' データ転記 For i = 2 To LastRow ' 1行目はヘッダーとしてスキップ ' Sheet1からSheet2へ値のみ転記 Sheets("Shee…
Sub CreatePivotTableWithPrompt() Dim ws As Worksheet Dim pt As PivotTable Dim pc As PivotCache Dim rngData As Range Dim rngDest As Range Dim response As VbMsgBoxResult ' データ範囲を指定します。適切に変更してください。 Set ws = ThisWorkboo…
Sub CreatePivotTableWithFormat() Dim ws As Worksheet Dim pt As PivotTable Dim pc As PivotCache Dim rngData As Range Dim rngDest As Range ' データ範囲を指定します。適切に変更してください。 Set ws = ThisWorkbook.Worksheets("Sheet1") Set rngD…
Sub CopyData1() Dim sourceSheet As Worksheet Dim targetSheet As Worksheet Dim lastRow As Long ' ソースシート(コピー元のシート)とターゲットシート(コピー先のシート)を設定 Set sourceSheet = ThisWorkbook.Sheets("Sheet1") Set targetSheet = …
Sub 編集結果を転記する()'売上見込み編集 Dim sourceSheet As Worksheet Dim targetSheet As Worksheet Dim lastRow As Long Dim i As Long Dim targetRow As Long Dim targetColumn As Long Dim sourceColumns As Long '編集結果シート初期化 Sheets("編集…
Option ExplicitSub sheet初期化() Columns("A:H").Select Selection.ClearContents Range("A1").SelectEnd SubSub 売上編集結果()'出品した商品 販売利益データのデータから編集 Dim sourceSheet As Worksheet Dim targetSheet As Worksheet Dim lastRow As…
Sub CreateTableOfContents() Dim ws As Worksheet Dim tocSheet As Worksheet Dim rowNum As Integer Dim sheetNum As Integer ' 新しいシートを作成して目次を作成 Set tocSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheet…
Option ExplicitSub 最短納期抽出() Dim wsSource As Worksheet Dim wsDestination As Worksheet Dim lastRowSource As Long Dim lastRowDest As Long Dim sourceRange As Range Dim destRange As Range Dim dict As Object Dim key As Variant Dim rowNum A…
Sub AddSheetWithDate() Dim ws As Worksheet Dim newSheet As Worksheet Dim templateSheet As Worksheet Dim sheetName As String Dim templateFound As Boolean ' 今日の日付をMMDD形式で取得 sheetName = Format(Date, "mmdd") ' すでに同じ名前のシート…
Dim FilePathFilePath = "D:\ThinkpadMark3\自学\filename変更_bat類\.xlsm\繰り返しCopy.xlsm" Dim appSet app = CreateObject("Excel.Application")app.Visible = trueapp.Workbooks.Open FilePathapp.Run "Module1.繰り返し" app.DisplayAlerts = False a…
Sub 昨日の日付をセルに出力() Dim 昨日 As Date Dim yyyymmdd As String ' 昨日の日付を計算 昨日 = Date - 1 ' yyyymmdd形式で文字列に変換 yyyymmdd = Format(昨日, "yyyymmdd") ' セルA1に文字列を出力 Sheets("sheet1").Range("A1").Value = yyyymmddEnd…
Sub ExportToExcelAndCompress() Dim xlApp As Object Dim xlBook As Object Dim rs As Recordset Dim strSQL As String Dim filePath As String ' エクスポートするデータのクエリを指定 strSQL = "SELECT * FROM YourTableName" ' データをレコードセット…
Sub ExportAndCompressData() Dim rs As Recordset Dim db As Database Dim strSQL As String Dim exportPath As String Dim zipPath As String Dim zipFileName As String Dim shellApp As Object ' エクスポートするデータのクエリを指定 strSQL = "SELECT…
Sub ExportDataInBatches() Dim rs As Recordset Dim db As Database Dim strSQL As String Dim batchCount As Integer Dim batchSize As Integer Dim recordCount As Long Dim i As Integer ' バッチサイズとエクスポートするデータの数を設定 batchSize = …