0
0

More than 1 year has passed since last update.

Excelファイルの特定のセルをタイトルと同じ名前にする(自動更新)

Posted at

以下プログラムをVBAのThisWorkBookに貼り付ける

Private Sub Workbook_Open()

' 変更するセルのアドレスと変更したい値を設定します
Dim targetCellAddress As String
targetCellAddress = "A1" ' 例: セルA1を変更したい場合

' タイトルを取得します
fileTitle = ThisWorkbook.Name
fileTitle = Left(fileTitle, Len(fileTitle) - 5) ' 拡張子を含まないように削除します


Dim newValue As Variant
newValue = fileTitle ' 例: 新しい値を "新しい値" に設定します

' タイトルに基づいてセルの値を変更します
ThisWorkbook.Sheets(1).Range(targetCellAddress).Value = newValue

MsgBox "名称が更新されました。"
    
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0