I need to find the next empty cell in column B (coluna_amostras variable), save its address (using the inserir variable) and use it to insert new row data. However, I could not figure out how to save the address in the inserir variable. As it is defined, excel returns "Runtime Error 91 - An object variable or with an undefined block variable." Can someone help me? Thank!!
Sub CopiarOriginais()
Dim Certeza As VbMsgBoxResult
Dim sample As String
Dim coluna_amostras As Range
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
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
source
share