助けてくれてありがとう。私はそれを理解し、必要なことを実行するためのコードをうまく思いつきました。もう 1 つ質問があります。お役に立てれば幸いです。私のコードを添付します。太字部分に注意してください。sourceSheet をシートとしてコピーし、targetSheet (「NewBook」の Sheet2) に貼り付けたいのですが、値として貼り付けたいです。これは、見る必要がある特定の部分です...そして以下は完全なコードです。
Set sourceBook = Application.Workbooks.Open(sourceFilename)
Set sourceSheet = sourceBook.Sheets("Current")
Set targetSheet = NewBook.Sheets("Sheet2")
sourceSheet.Copy targetSheet
Set targetSheet = NewBook.Sheets("Current")
targetSheet.Name = "Previous"
Sub Subtype()
Dim sourceBook As Workbook
Dim filter As String
Dim caption As String
Dim sourceFilename As String
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
If customerFilename = "False" Then
' GoTo Here:
End If
filter = "Text files (*.xlsx),*.xlsx"
caption = "Please Select an input file "
sourceFilename = Application.GetOpenFilename
Set NewBook = Workbooks.Add
With NewBook
.Title = "Subtype Practice"
End With
Set sourceBook = Application.Workbooks.Open(sourceFilename)
Set sourceSheet = sourceBook.Sheets("Current")
Set targetSheet = NewBook.Sheets("Sheet2")
sourceSheet.Copy targetSheet
Set targetSheet = NewBook.Sheets("Current")
targetSheet.Name = "Previous"
sourceBook.Close
Dim sourceBook1 As Workbook
Dim sourceFilename1 As String
Dim sourceSheet1 As Worksheet
Dim targetSheet1 As Worksheet
sourceFilename1 = Application.GetOpenFilename
Set sourceBook1 = Application.Workbooks.Open(sourceFilename1, Password:="BMTBD")
Set sourceSheet1 = sourceBook1.Sheets("Data")
Set targetSheet1 = NewBook.Sheets("Sheet1")
sourceSheet1.Copy targetSheet1
Set targetSheet1 = NewBook.Sheets("Data")
targetSheet1.Name = "Current"
Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Application.DisplayAlerts = True
End Sub