I Need help speeding up this code that takes about 5 mins to run copying data from multiple columns and combining them

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have a sheet that has columns A to BX with data
then I have another sheet were I want to copy the data to make one big column
but its super slow,

I was wouldering if anyone could think of a way to speed it up?
happy for a total reright

heres my code

VBA Code:
Sub Make_Single_Gig_List()
Dim StartTime As Double
Dim SecondsElapsed As Double
  StartTime = Timer

Application.Calculation = xlManual
Application.ScreenUpdating = False
Sheets("Gig Diary 1 Row").AutoFilterMode = False
Sheets("Gig Diary 1 Row").Range("A2:T25000").EntireRow.Delete

Z = 6

For x = 5 To 75 Step 2
Application.StatusBar = "Progress: " & x & " of 75: " & Format(x / 100, "Percent")


i = Split(ActiveSheet.Cells(2, x).Address, "$")(1)
j = Split(ActiveSheet.Cells(2, Z).Address, "$")(1)

GLR = Sheets("Gig Diary").Cells(Rows.Count, "A").End(xlUp).Row
RLR = Sheets("Gig Diary 1 Row").Cells(Rows.Count, "A").End(xlUp).Row + 1
ELR = GLR + RLR - 3

Sheets("Gig Diary").Range("A3:C" & GLR).Copy Sheets("Gig Diary 1 Row").Range("A" & RLR, "C" & ELR) 'Date+Band+Status
Sheets("Gig Diary").Range("D3:D" & GLR).Copy Sheets("Gig Diary 1 Row").Range("G" & RLR, "G" & ELR) 'Venue address
Sheets("Gig Diary").Range("CB3:CB" & GLR).Copy Sheets("Gig Diary 1 Row").Range("H" & RLR, "H" & ELR) 'music
Sheets("Gig Diary").Range("CE3:CE" & GLR).Copy Sheets("Gig Diary 1 Row").Range("I" & RLR, "I" & ELR) 'type of event
Sheets("Gig Diary").Range(i & "1").Copy Sheets("Gig Diary 1 Row").Range("F" & RLR, "F" & ELR) 'instument
Sheets("Gig Diary").Range(i & "3", j & GLR).Copy Sheets("Gig Diary 1 Row").Range("D" & RLR, "E" & ELR) 'Name + Fee

Z = Z + 2

Next x

Application.StatusBar = "Progress: " & x & " of 100: " & Format(x / 100, "Percent")

Application.Calculation = xlAutomatic
Application.StatusBar = False

  SecondsElapsed = Round(Timer - StartTime, 2)
  MsgBox "This code ran successfully in " & SecondsElapsed & " seconds", vbInformation
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm not sure if I imagined it, but when I had information going to the status bar, my workbook seemed to slow quite a bit. Maybe try commenting out those lines and see how long it takes.
 
Upvote 0
Hi Candyman,
I just tried that and the results were uncertain.
the thing is it takes so long to run if we do not have that it feels like it's just frozen.
I realize sometimes code is just slow, but I had hoped maybe someone could spot a fundamental problem with my code and shazam! everything is fast again,
I had it super fast when I only needed the data but now I need the formating so I have to copy everything over and that seams to be slowing it down big style.
Thanks for your help.
Tony
 
Upvote 0
It looks like you’re needlessly repeating this section of code 35 times. It is copy and pasting the exact same ranges each time. Perhaps it could be put outside of the loop? Of course without seeing the actual sheet I’m trying to visualize what you might be trying to accomplish.

VBA Code:
Sheets("Gig Diary").Range("A3:C" & GLR).Copy Sheets("Gig Diary 1 Row").Range("A" & RLR, "C" & ELR) 'Date+Band+Status
Sheets("Gig Diary").Range("D3:D" & GLR).Copy Sheets("Gig Diary 1 Row").Range("G" & RLR, "G" & ELR) 'Venue address
Sheets("Gig Diary").Range("CB3:CB" & GLR).Copy Sheets("Gig Diary 1 Row").Range("H" & RLR, "H" & ELR) 'music
Sheets("Gig Diary").Range("CE3:CE" & GLR).Copy Sheets("Gig Diary 1 Row").Range("I" & RLR, "I" & ELR) 'type of event
 
Upvote 0
Yes, it needs to repeat that many times,
those 4 areas are details that are the same for everyone,
then we have columns i & J which are the ones that move,
its hard to describe the document but every thing of one job is in one row at the moment,
so for example it might say
12/05/2023 New JOB The High Street
DateTypeADDTimeName1FeeName 2Feeand it carries on with names in each so clusters or two
12/3newthe st12Bob100Tom200Barry300
but what i want is all names in one row
Datetypeaddtimenamefee
12/3newthe st12bob100
12/3newthe st12tom200
12/3newthe st12barry300
Like the above but with multiple lines and many more columns
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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