excel vba - Simplify a code -


the first part of code works well, can make more simple, second code? have tried second, excel returns "run-time error 1004 - application-defined or object-defined error".

            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, tried use inserir.row, excel keeps returning same error. below, complete code. have suggestion?

sub copiaroriginais()

    dim certeza vbmsgboxresult     dim sample string     dim inserir 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 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 

the second should work fine, think, you're using "i" instead of "d" in range. also, you're using inserir instead of inserir.row. think it's simple error that. theoretically should work fine.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -