Slow VBA code

Gylle

New Member
Joined
Apr 10, 2022
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hi
I have this VBA script that i got to work

But it runs really slow. For me it takes about 1 min to preform the whole thing.

i was wondering if there waas a way to make it run faster or mabey optimise it?

VBA Code:
Private Sub Worksheet_Activate()

 
 Ark16.Range("F5").Copy
 Range("F2,I2").PasteSpecial xlPasteValues
 Ark16.Range("F6").Copy
 Range("F3,I3").PasteSpecial xlPasteValues
 
 Ark16.Range("F14").Copy
 Range("F4,I4").PasteSpecial xlPasteValues
 Ark16.Range("F15").Copy
 Range("F5,I5").PasteSpecial xlPasteValues
 
 Ark16.Range("F23").Copy
 Range("F6,I6").PasteSpecial xlPasteValues
 Ark16.Range("F24").Copy
 Range("F7,I7").PasteSpecial xlPasteValues
 
 Ark16.Range("F32").Copy
 Range("F8,I8").PasteSpecial xlPasteValues
 Ark16.Range("F33").Copy
 Range("F9,I9").PasteSpecial xlPasteValues
 
 Ark16.Range("F41").Copy
 Range("F10,I10").PasteSpecial xlPasteValues
 Ark16.Range("F42").Copy
 Range("F11,I11").PasteSpecial xlPasteValues


Application.CutCopyMode = False

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Do you mean something like this?

VBA Code:
Private Sub Worksheet_Activate()

 
 Range("F2,I2").Value2 = Ark16.Range("F5").Value2
 Range("F3,I3").Value2 = Ark16.Range("F6").Value2
 
 Range("F4,I4").Value2 = Ark16.Range("F14").Value2
 Range("F5,I5").Value2 = Ark16.Range("F15").Value2
 
 Range("F6,I6").Value2 = Ark16.Range("F23").Value2
 Range("F7,I7").Value2 = Ark16.Range("F24").Value2
 

 Range("F8,I8").Value2 = Ark16.Range("F32").Value2
 Range("F9,I9").Value2 = Ark16.Range("F33").Value2
 
 Range("F10,I10").Value2 = Ark16.Range("F41").Value2
 Range("F11,I11").Value2 = Ark16.Range("F42").Value2


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top