Avatar billede Jaaen Juniormester
07. april 2021 - 12:42 Der er 8 kommentarer og
3 løsninger

VBA der kopiere flere uafhængige områder til andre uafhængige områder

Hej alle,

Jeg har brug for Jeres hjælp.

Jeg har et excel ark, hvor jeg pt via en makro jeg har "indspillet" for lavet en LANG række "Kopier" -> "Indsæt værdi" via ca. 100 uafhængige områder.

Problemet er nu at når den køres af brugeren, så er den 1) langsom, og 2) den "flimrer" idet jeg i min indspilning var nødt til at "Scrolle" undervejs for at kunne lave kopieringen.

Jeg er meget ny med VBA, men jeg tænker opgaven kan løses derigennem?

Et eksempel på hvad jeg ønsker mig;

Kopier indholdet af Cellerne C29:C38 og "indsæt værdi" i Cellerne U29:U38
Derefter (og i samme "kørsel") kopier E65 og "indsæt værdi" i celle W65

osv osv. med ca. 100 kopieringer total.

Det er vigtigt at det er "indsæt værdi" i de fleste tilfælde, da der er data-validering på de fleste felter. I enkelte undtagelser, skal jeg have fat i "indsæt Formler".

Kan det trylles smart?
Avatar billede ebea Ekspert
07. april 2021 - 12:56 #1
Hvis du kan trylle dit Ark frem, så det kan ses hvad det eksakt går ud på, vil det nok gøre det nemmere.
Avatar billede Jaaen Juniormester
07. april 2021 - 13:08 #2
Hej @Ebea

Link til screenshot:

https://paste.pics/d02d30279ebf8151f24e981c59a44759


Jeg har brug for at makroen/VBA'en kopiere alle felterne med hvid baggrund og rødt omrids til deres tilsvarende placering med grøn baggrund og rødt omrids.

Sektioner som denne har jeg 8 af, hvor opbygningen er den sammen, men hvor rækkenummeret naturligvis ændrer sig.

Derudover nogle som er mindre regelmæssige, hvor enkelte felter skal være formler og hvor enkelte felter skal være værdier.

Giver det mening sådan?
Avatar billede kim1a Ekspert
07. april 2021 - 13:18 #3
Jeg vil tro den nemme løsning er at rydde op i din optagede makro, så kan det være det lige så stille også giver mening for dig.
Kopier den herind.
Avatar billede Jaaen Juniormester
07. april 2021 - 14:13 #4
Det kunne godt lyde som en plan - den optagede makro kommer her:

Den ALLERsidste del er blot lavet, for at undgå at en celle sidder fast i i "udklipsholder" for brugere når de har trykket på knappen.

Makroen:

Sub CopyMaterials()
'
' CopyMaterials Makro
'

'
    Range("C29:C38").Select
    Selection.Copy
    Range("U29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E29:E38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G29:G38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J29:J38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L29:L38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P29:P38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R29:R38").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ29").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C41:C50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E41:E50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G41:G50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J41:J50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L41:L50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P41:P50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R41:R50").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=15
    Range("C53:C62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E53:E62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G53:G62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J53:J62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L53:L62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("N53:N62").Select
    Selection.Copy
    Range("AF53").Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Range("P53:P62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R53:R62").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ53").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=12
    Range("C64").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U64").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E65").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W65").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J65").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB65").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R65").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ65").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E67:E68").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W67").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G67:G68").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y67").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J68").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB68").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L67:L68").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD67").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P67:P68").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH67").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E70:E71").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W70").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G70:G71").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y70").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L70:L71").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD70").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("AH70:AH71").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C66:C71").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U66").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P70:P71").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH70").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=12
    Range("C73").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U73").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E74").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W74").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J74").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("J74").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB74").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R74").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ74").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C75:C80").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U75").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E75:E80").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W75").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G75:G80").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y75").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J76:J77").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB76").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L76:L77").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD76").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L79:L80").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD79").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P76:P77").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH76").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P79:P80").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH79").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R74").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ74").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=9
    Range("C82").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U82").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E83").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W83").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J83").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB83").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R83").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ83").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C84:C89").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U84").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E84:E89").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W84").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G84:G89").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y84").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J85:J86").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB85").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L85:L86").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD85").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P85:P86").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH85").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L88:L89").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD88").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P88:P89").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH88").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=9
    Range("C91").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U91").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E92").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W92").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J92").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB92").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R92").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ92").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C93:C98").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U93").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E93:E98").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W93").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G93:G98").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y93").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J94:J95").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB94").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L93:L98").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD93").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P94:P95").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH94").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P97:P98").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH97").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=9
    Range("C91").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U91").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C100").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U100").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E101").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W101").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J101").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB101").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R101").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ101").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C102:C107").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U102").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E102:E107").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W102").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G102:G107").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y102").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J103:J104").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB103").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L102:L107").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD102").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P103:P104").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH103").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P106:P107").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH106").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=12
    Range("C111:C120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E111:E120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G111:G120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J111:J120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L111:L120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P111:P120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R111:R120").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ111").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=9
    Range("C123:C132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E123:E132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G123:G132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J123:J132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L123:L132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P123:P132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R123:R132").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ123").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=15
    Range("C135:C144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E135:E144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G135:G144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J135:J144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L135:L144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P135:P144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R135:R144").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ135").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=12
    Range("C146").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U146").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E147").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W147").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G147").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y147").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J147").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB147").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R147").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ147").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C149:C153").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U149").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E149:E153").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W149").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G149:G153").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y149").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L149:L153").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD149").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P149:P153").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH149").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C155").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U155").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E156").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W156").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G156").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y156").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J156").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB156").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R156").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ156").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C158:C162").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U158").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E158:E162").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W158").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G158:G162").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y158").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L158:L162").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD158").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P158:P162").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH158").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=18
    Range("C164").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U164").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E165").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W165").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G165").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y165").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J165").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB165").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R165").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ165").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C167:C171").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U167").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E167:E171").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W167").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G167:G171").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y167").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L167:L171").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD167").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P167:P171").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH167").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C173").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U173").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E174").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W174").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G174").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y174").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J174").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB174").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R174").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ174").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C176:C180").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U176").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E176:E180").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W176").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("G176:G180").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("Y176").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L176:L180").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD176").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P176:P180").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH176").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=3
    Range("C182").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("U182").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E183").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W183").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("J183").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AB183").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L183").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AD183").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("R183").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AJ183").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("E186").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("W186").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("P186").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AH186").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveWindow.SmallScroll Down:=-138
    Range("P26").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "NEW"
    Range("P26").Select
End Sub
Avatar billede ebea Ekspert
07. april 2021 - 14:38 #5
At vise et billede, er ikke dit Ark. Og at din kode er langsom, skyldes alle de "Selections" du har i koden.
Avatar billede Jan K Ekspert
07. april 2021 - 15:00 #6
Og du kan 6ndgå "flimren" ved at begynde med

Application.Screenupdating = False

Og sluttd med at sætte det til True igen
Avatar billede Jan K Ekspert
07. april 2021 - 15:05 #7
For mig at se, virker de områder, dercskal kopieres uden systematik, hvilket gør det vanskeligt, fx at kave en løkke, der løber dem igennem.
Avatar billede Jaaen Juniormester
07. april 2021 - 15:17 #8
Hej Jan,

Tak for tippet med Screenupdating - det virker rigtig godt, tak - det hjælper en hel del.

Kan jeg gøre den hurtigere ved at få markeret alle de celler der skal kopieres på en gang og få dem indsat på en omgang?

lige nu, tager den jo 1 område ad gangen og starter forfra med ny område?

Det er et input ark, som på grund af diverse forklaringer osv osv ikke er 100% systematisk i sin opbygning - dog er det HELT systematisk at de felter som skal kopieres altid skal indsættes 18 kolonner til højre (alt det der skal kopieres fra Kolonne E skal altid indsættes i kolonne W) - men det er så ikke alle rækker der skal kopieres.
Avatar billede ebea Ekspert
07. april 2021 - 15:58 #9
En lidt hurtigere måde. Og så kan du tilføje lidt nedefter.

Sub CopyMaterials()

        Range("C29:G38").Copy Range("W29")
        Range("J29:L38").Copy Range("AB29")
        Range("P29:R38").Copy Range("AH29")
       
End Sub
Avatar billede Jaaen Juniormester
07. april 2021 - 17:18 #10
tak @ebea - den metode vil jeg straks prøve!
Avatar billede ebea Ekspert
07. april 2021 - 17:42 #11
#10 - Der er som skrevet andetsteds, ikke struktur nok i dine rækker, til at kunne lave et loop, som havde været hurtigere, da der jo er 18 kolonner mellem det kopierede og indsatte.
Jeg lavede et lidt længere eks., men det bliver stadig en lang kode (alt er relativet).
Men det skærer en stor del væk af dit Select kode, og så er det meget hurtigere.

Sub CopyMaterials()

        Range("C29:G38").Copy Range("U29")
        Range("J29:L38").Copy Range("AB29")
        Range("P29:R38").Copy Range("AH29")
        Range("C41:G50").Copy Range("U41")
        Range("J41:L50").Copy Range("AB41")
        Range("P41:R50").Copy Range("AH41")
        Range("C53:G62").Copy Range("U53")
        Range("J53:L62").Copy Range("AB53")
        Range("P53:R62").Copy Range("AH53")
        Range("C64").Copy Range("U64")
        Range("E65").Copy Range("W65")
        Range("J65").Copy Range("AB65")
        Range("R65").Copy Range("AJ65")
        Range("E67:G68").Copy Range("W67")
        Range("J68").Copy Range("AB68")
        Range("L67:L68").Copy Range("AD67")
        Range("P67:P68").Copy Range("AH67")
        Range("E70:G71").Copy Range("W70")
        Range("L70:L71").Copy Range("AD70")
        Range("C66:C71").Copy Range("U66")
        Range("P70:P71").Copy Range("AH70")
        Range("C73:E74").Copy Range("U73")
        Range("J74").Copy Range("AB74")
        Range("R74").Copy Range("AJ74")
        Range("C75:G80").Copy Range("U75")
        Range("J76:L77").Copy Range("AB76")
       
End Sub
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi har et stort udvalg af Excel kurser. Find lige det kursus der passer dig lige her.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester