Slow VBA code

Gylle

New Member
Joined
Apr 10, 2022
Messages
44
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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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