0
代碼的第一部分工作得很好,但我可以使它更簡單,就像第二個代碼?我已經嘗試了第二次,但是excel返回「運行時錯誤1004 - 應用程序定義或對象定義的錯誤」。簡化代碼
Worksheets(sample).Range("ratio143144").Copy
Worksheets("Results").Activate
Range("D" & inserir.Row).Select
ActiveSheet.PasteSpecial Link:=True
Worksheets(sample).Range("ratio146144").Copy
Worksheets("Results").Range("I" & inserir).PasteSpecial Link:=True
GolezTrol,我試圖用inserir.row,但創先爭優保持返回相同的錯誤。下面是完整的代碼。你有什麼建議嗎?
子CopiarOriginais()
Dim Certeza As VbMsgBoxResult
Dim sample As String
Dim inserir As Range
ActiveSheet.Name = Range("Y1").Value
sample = Range("Y1").Value
Certeza = MsgBox("Você tem certeza de que os dados originais já não foram copiado? Utilizar novamente essa função, após o teste 2-sigma ter sido aplicado, comprometerá os seus dados originais.", vbYesNo)
If Certeza = vbNo Then End
Sheets("Results").Activate
Range("B2").End(xlDown).Offset(1, 0).Select
Set inserir = ActiveCell
Sheets(sample).Activate
Range("B3:D122").Copy
Range("B132").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Worksheets(sample).Range("ratio143144").Copy
Worksheets("Results").Activate
Range("D" & inserir.Row).Select
ActiveSheet.PasteSpecial Link:=True
Worksheets(sample).Range("ratio146144").Copy
Worksheets("Results").Activate
Range("I" & inserir.Row).Select
ActiveSheet.PasteSpecial Link:=True
' Worksheets("Results").Range("I" & inserir.Row).PasteSpecial Link:=True
Worksheets(sample).Range("ratio145144").Copy
Worksheets("Results").Range("G" & inserir.Row).PasteSpecial Link:=True
Worksheets(sample).Range("ratio1431442se").Copy
Worksheets("Results").Range("F" & inserir).PasteSpecial Link:=True
Worksheets(sample).Range("ratio1451442se").Copy
Worksheets("Results").Range("H" & inserir).PasteSpecial Link:=True
Worksheets(sample).Activate
Range("A1").Select
End Sub