I have to find the next empty cell in column B (variable coluna_amostras), save its address (using variable inserir) and use it to paste a new row data. However, I couldn't figure out how to store the address in inserir variable. As it´s defined, excel returns "Run-time error 91 - Object variable or with block variable not set". Could someone help me? Thanks!!
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
inserir = ActiveCell
is the same asinserir.Value = ActiveCell.Value
, which fails becauseinserir
isNothing
.If want to save a reference to an object, you must use
Set
:You need to set the value