つらつら Excel VBA

私の備忘録です。

2019-02-10から1日間の記事一覧

フォーム上でログ表示したい

'formにListBoxを用意して、Moduleに以下を追加 Private Sub LogAdd(s As String) If s = "" Then Exit Sub With UserForm1.LstBox_Log .AddItem s .ListIndex = .ListCount - 1 '最後尾を選択 .Selected(.ListCount - 1) = False '選択解除 End With DoEven…

オートフィルタで重複データを抽出

Sub Macro1() ' 重複データに色をつける条件付き書式 Range("B:B").Select Range("B:B").FormatConditions.Delete Selection.FormatConditions.AddUniqueValues '条件付き書式の追加 Selection.FormatConditions(1).DupeUnique = xlDuplicate '重複 Selectio…

カレントディレクトリの変更とファイル選択ダイアログの表示場所

Private Sub readLineTextFile() Dim fType As String, promptText As String, chDirPath As String Dim fPath As Variant Dim buf As String 'カレントディレクトリを移動 curDirPath = CurDir ChDir ActiveWorkbook.Path fType = "テキストファイル (*.txt…