投稿

5月, 2022の投稿を表示しています

連想配列でルックアップな方法 背景色を抽出

Quick Edit Pencil


Sub aaa()

'***** 部門.マスター *****

    Dim 部門辞書 As Object
    Set 部門辞書 = CreateObject("Scripting.Dictionary")
    
    For Each セル In range("B2:G2") 'range("部門識別子")
        部門辞書.Add セル.Value, セル.Interior.Color
    Next
    
    Debug.Print 部門識別カラー("HO")

End Sub

エクセル セル選択範囲 複数

Quick Edit Pencil
Union(range("選択範囲1"), range("選択範囲2")).Select

range("選択範囲1,選択範囲2").Select

VBA 選択範囲の任意の列のRange(R1C1)を取得

Quick Edit Pencil
Debug.Print ConvertToLetter(Selection.Column) & Selection.Row & ":" & _ConvertToLetter(Selection.Column) & Selection.Rows(Selection.Rows.Count).Row
        
Debug.Print Range(Cells(Selection.Row, 2), Cells(Selection.Rows(Selection.Rows.Count).Row, 2)).Address
        
Debug.Print Selection.Columns(2).Address

excel入力規則メモ

Quick Edit Pencil
B15 =大分類コード

C15 =INDIRECT(LOOKUP($B15,大・中分類一覧!$4:$4,大・中分類一覧!$2:$2))



WindowDOM vba html

Quick Edit Pencil
リンク
WindowDOM vba html - 検索

vba FindWindow

Quick Edit Pencil

ウインドウ一覧のクラス名とキャプション名を取得する()




WindowsAPIを用いてウインドウの一覧表を作成するVBAコード | VBA・GAS・Pythonで仕事を楽しく効率化
vba FindWindow - 検索
  1. 'ウインドウハンドルを取得する
  2. Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  3. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  4.  
  5. 'ウインドウが可視かどうかを取得する
  6. Declare Function IsWindowVisible Lib "user32" _
  7. (ByVal hWnd As Long) As Long
  8.  
  9. 'ウインドウのキャプションタイトルを取得する
  10. Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
  11. (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  12.  
  13. 'ウインドウのクラス名を取得する
  14. Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
  15. (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
  16.  
  17. '取得中のウインドウの次または前のウインドウハンドルを取得する
  18. Declare Function GetNextWindow Lib "user32" Alias "GetWindow" _
  19. (ByVal hWnd As Long, ByVal wFlag As Long) As Long
  20.  
  21. Const GW_HWNDLAST = 1
  22. Const GW_HWNDNEXT = 2
  23.  
  24. Sub ウインドウ一覧のクラス名とキャプション名を取得する()
  25.  
  26. Dim i As Long
  27. i = 1
  28.  
  29. Dim strClassName As String * 100
  30. Dim strCaption As String * 80
  31.  
  32. Dim hWnd As Long
  33. hWnd = FindWindow(vbNullString, vbNullString) '引数を両方ともvbNullStringにして1つめのウインドウを取得する
  34.  
  35. Do
  36. If IsWindowVisible(hWnd) Then
  37. GetWindowText hWnd, strCaption, Len(strCaption)
  38. GetClassName hWnd, strClassName, Len(strClassName)
  39.  
  40. Cells(i, 1).Value = strClassName
  41. Cells(i, 2).Value = strCaption
  42.  
  43. 'Cells(i, 1).Value = Left(strClassName, InStr(strClassName, vbNullChar) ? 1)
  44. 'Cells(i, 2).Value = Left(strCaption, InStr(strCaption, vbNullChar) ? 1)
  45.  
  46. i = Application.WorksheetFunction.Max(Cells(60000, 1).End(xlUp).Row, Cells(60000, 2).End(xlUp).Row, Cells(60000, 3).End(xlUp).Row) + 1
  47.  
  48. End If
  49.  
  50. hWnd = GetNextWindow(hWnd, GW_HWNDNEXT)
  51.  
  52. Loop Until hWnd = GetNextWindow(hWnd, GW_HWNDLAST)
  53.  
  54. End Sub

VBAでWindowsAPIを用いてウインドウを取得する手順について | VBA・GAS・Pythonで仕事を楽しく効率化