将粘贴数据复制到另一个工作簿中的一行,每次保存时更新列
我正在尝试将一排从一个工作簿复制到另一个工作簿。有3列将在不同的日期上更新,每次我想将其保存到目的地时,都不会替换行,而是将其转到另一行。我希望代码每次粘贴时都会替换现有数据。我想避免粘贴现有列或对其进行更新,以便结果在一行中。
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("M11:M12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(lastRow, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("N11") = "" Then
MsgBox "Confirm 'Pre & 1st Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("N11:N12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "C").End(xlUp).Row + 1
Cells(lastRow, 3).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("O11") = "" Then
MsgBox "Confirm 'Pre & Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("O11:O12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "E").End(xlUp).Row + 1
Cells(lastRow, 5).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("P11") = "" Then
MsgBox "Confirm 'Pre & Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("P11:P12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "G").End(xlUp).Row + 1
Cells(lastRow, 7).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("M11:P12").ClearContents
MsgBox "SOURCE STRENGTH VERIFICATION RESULTS SAVED SUCCESSFULLY"
ActiveSheet.Protect
End If
初始表
保存第二次后
I'm trying to copy paste a row from one workbook to another. There are 3 columns which will be updated on different dates, and each time I want to save it to destination it is not replacing the row, instead it is going to another row. I want code to replace the existing data every time I paste.I want to avoid pasting the existing column or update it so that the results are in one row.
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("M11:M12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(lastRow, 1).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("N11") = "" Then
MsgBox "Confirm 'Pre & 1st Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("N11:N12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "C").End(xlUp).Row + 1
Cells(lastRow, 3).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("O11") = "" Then
MsgBox "Confirm 'Pre & Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("O11:O12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "E").End(xlUp).Row + 1
Cells(lastRow, 5).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
End If
If Range("P11") = "" Then
MsgBox "Confirm 'Pre & Post'source exchange RAKR measurement completed"
Else
dstn = "S:\Radiotherapy-Department\Brachytherapy\Spreadsheets\Developement\Josmi_Project _ DB\Postsource exchangeResults.xlsx"
Workbooks.Open (dstn)
Sheets("Result-1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("P11:P12").Copy
lastRow = Sheets("Result-1").Cells(Rows.Count, "G").End(xlUp).Row + 1
Cells(lastRow, 7).PasteSpecial Paste:=xlPasteValues, Transpose:=True
ActiveSheet.Protect
ThisWorkbook.Sheets("FORM.HDR 1.1").Activate
ActiveSheet.Unprotect
ThisWorkbook.Sheets("FORM.HDR 1.1").Range("M11:P12").ClearContents
MsgBox "SOURCE STRENGTH VERIFICATION RESULTS SAVED SUCCESSFULLY"
ActiveSheet.Protect
End If
Initial Table
this is the first table. sorry
Result after saving the second time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论