Excelで結合セルを一括で拡張・縮小
「個人用マクロブック」PERSONAL.XLSB という機能があり、 Excel起動時に自動で開かれる、どのExcelファイルでも使える、自作マクロを保存できるので、これを使う。
まず作成方法。
Excel起動 「表示」タブ 「マクロの記録」 保存先で「個人用マクロブック」を選択 OK すぐ記録停止 これで PERSONAL.XLSB が作られる。
次に開く方法。
Alt + F11 VBAエディタ左側のプロジェクト一覧
ここにVBAProject (PERSONAL.XLSB)が出るので、その中の Modules → Module1 へマクロを貼る。
Sub 結合右縮小()
Dim dic As Object
Dim c As Range
Dim ma As Range
Dim k
Dim addr()
Set dic = CreateObject("Scripting.Dictionary")
For Each c In Selection.Cells
If c.MergeCells Then
If Not dic.Exists(c.MergeArea.Address) Then
dic.Add c.MergeArea.Address, c.MergeArea.Address
End If
End If
Next
ReDim addr(0 To dic.Count - 1)
Dim i As Long
i = 0
For Each k In dic.Keys
addr(i) = k
i = i + 1
Next
For i = 0 To UBound(addr)
Set ma = Range(addr(i))
If ma.Columns.Count > 1 Then
Dim r As Long
Dim col As Long
Dim row0 As Long
Dim col0 As Long
r = ma.rows.Count
col = ma.Columns.Count
row0 = ma.Row
col0 = ma.Column
ma.UnMerge
Range( _
Cells(row0, col0), _
Cells(row0 + r - 1, col0 + col - 2) _
).Merge
End If
Next
End Sub
Sub 結合右拡張()
Dim dic As Object
Dim c As Range
Dim ma As Range
Dim k
Dim addr()
Set dic = CreateObject("Scripting.Dictionary")
For Each c In Selection.Cells
If c.MergeCells Then
If Not dic.Exists(c.MergeArea.Address) Then
dic.Add c.MergeArea.Address, c.MergeArea.Address
End If
End If
Next
ReDim addr(0 To dic.Count - 1)
Dim i As Long
i = 0
For Each k In dic.Keys
addr(i) = k
i = i + 1
Next
For i = 0 To UBound(addr)
Set ma = Range(addr(i))
Dim r As Long
Dim col As Long
Dim row0 As Long
Dim col0 As Long
r = ma.rows.Count
col = ma.Columns.Count
row0 = ma.Row
col0 = ma.Column
ma.UnMerge
Range( _
Cells(row0, col0), _
Cells(row0 + r - 1, col0 + col) _
).Merge
Next
End Sub
Sub 結合右移動()
Dim dic As Object
Dim c As Range
Dim ma As Range
Dim k
Dim addr()
Set dic = CreateObject("Scripting.Dictionary")
For Each c In Selection.Cells
If c.MergeCells Then
If Not dic.Exists(c.MergeArea.Address) Then
dic.Add c.MergeArea.Address, c.MergeArea.Address
End If
End If
Next
ReDim addr(0 To dic.Count - 1)
Dim i As Long
i = 0
For Each k In dic.Keys
addr(i) = k
i = i + 1
Next
For i = 0 To UBound(addr)
Set ma = Range(addr(i))
Dim txt As Variant
Dim r As Long
Dim col As Long
Dim row0 As Long
Dim col0 As Long
txt = ma.Cells(1, 1).Value
r = ma.rows.Count
col = ma.Columns.Count
row0 = ma.Row
col0 = ma.Column
ma.UnMerge
Range( _
Cells(row0, col0 + 1), _
Cells(row0 + r - 1, col0 + col) _
).Merge
Cells(row0, col0 + 1).Value = txt
Next
End Sub
ボタン追加は簡単。
ファイル オプション クイックアクセスツールバー 「コマンドの選択」で「マクロ」 追加
するとExcel左上にボタンが出る。
ARMv8(AArch64)でシステムカウンタのクロック周波数読み取り
CNTFRQ_EL0という読み取り専用レジスタがあり、カウンタ周期(Hz)を取得することができる。
#include <stdint.h>
#include <stdio.h>
void main(void)
{
uint64_t f;
asm volatile("mrs %0, cntfrq_el0" : "=r"(f));
printf("CNTFRQ = %lu Hz\n", f);
}
アイコンキャッシュの削除
Windowsアプリとかでアイコンを何度も変更していると、 アイコンキャッシュによって、変更したはずのアイコンが適用されないことが多々ある。
そんなときにアイコンキャッシュを削除するときは、このバッチでOK。 再起動は不要で、Explorerを停止した状態でキャッシュを削除してもう一度起動することでうまくいく。
@echo off taskkill /IM explorer.exe /F TIMEOUT /T 3 del /A /Q "%localappdata%\IconCache.db" del /A /F /Q "%localappdata%\Microsoft\Windows\Explorer\iconcache*" explorer.exe
Video編集
フリーの動画編集ソフトをを見つけたので、備忘録として記録しておく。
動画編集系はフリーだとUIが簡素すぎたりして、
あまり実用的ではないものが多い印象だったので、貴重な気がする。
Bluetooth規格の日程
BluetoothのSpecificationsを見れば日程が分かるようになっている
https://www.bluetooth.com/specifications/specs/
Document nameが、Core Specification (amended) がいわゆるBluetooth Versionの規格になる
Deprecationが非推奨で、Withdrawalが廃止という意味
たとえばVersion4.2だとDeprecationが 1 Feb 2026になっているため、2026年1月に非推奨になる
ただしこれは移行期間のようなもので、非推奨になっても認証自体は取れるものだと思うが
Withdrawalになると認証もとれず、つまり製品化もできなくなるという意味合い
Draw.ioで作成した画像をgit管理する
MermaidやPlantUMLの限界を感じていたので、Draw.ioを使いたい。
Draw.io Integrationというプラグインを使うことでVS Codeで編集できるようになる。
git上で画像を表示しつつdrawioで編集可能とするには、ベクターファイルにする必要があるが、
svgでも良いがgitクライアントのバージョンによって表示対応していない可能性もあるので、pngの方が無難。
Ctrl + Shift +Pで、Draw.io: New Draw.io Diagramを選択して、新規作成を行う。
XXXX.drawioという名前で作成する。
編集したあとは、XXXX.drawio.pngで書き出しすることで完了。
drawio.pngを直接編集できるようになるため、これ以降はXXXX.drawioは不要となる。