Is there a way to speed this up?

andyfleisher

New Member
Joined
May 25, 2011
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I made a short macro with the recorder (and a little editing) to just cut and paste cells from a the worksheet. The basic setup is that I copied the data from a website and it is has multiple rows of data for each entry that can really be on a single line.

The pasted data looks like this. In Excel, each line comes in as a separate row.

CRN
Time/Days
Course
Location
Section
Open/Reserved/Waitlist
Title
GE Credit
Instructor
Course Units
11111
8:00 - 8:50 AM, F
MGT 011A
Room1120
A01
13/0/0
Elementary Accounting
SS
Name
4.0

The macro takes the second row of cells and cuts/pastes it to the right of the line above. If run twice, it would look like this (including the blank cells)

CRNCourseSectionTitleInstructorTime/DaysLocationOpen/Reserved/WaitlistGE CreditCourse Units
11111MGT 011AA01Elementary Accounting
Name8:00 - 8:50 AM, FRoom112013/0/0SS4.0

I keep running into the annoying clipboard error that says I can't paste into a different application and added some wait time into the macro. I feel that this should run pretty quickly since it is just copying and pasting a few cells at a time and just looping over and over but it takes a while (even for just 10 iterations) and Excel seems to also hang for a but once things are done. The code is below. I have a basic input for the number of times to run the macro and that's about it.

VBA Code:
Sub CleanClassSearchData()
'
' Keyboard Shortcut: Ctrl+Shift+L
'
Application.ScreenUpdating = False
myNum = Application.InputBox("Enter the number of times to run the macro.")
For i = 0 To myNum
ActiveCell.Offset(1, 0).Range("A1:E1").Select
Selection.Cut
Application.Wait (Now + TimeValue("0:00:01"))
ActiveCell.Offset(-1, 5).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(2, -5).Range("A1").Select
Next i
Application.ScreenUpdating = True
End Sub

Thanks,
Andy
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also, can you give us a slightly larger set of dummy sample data "Before" and "After" with XL2BB so that we can be sure we are working with the same setup you have?
(If you have trouble with XL2BB review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of theXL2BB Instructions page linked above.)
 
Upvote 0
If the Cut/Paste and the clipboard is causing the issue, would just setting the values and then clearing the old cells work for your purpose?
 
Upvote 0
For people with the same or similar problem and that are looking for a solution, would you be so helpful and show them your solution.
After all you came here for help also, just like all of us and it is frustrating if you see a line of which you think that that will have an answer for you but you get nothing!!!!
 
Upvote 0

Forum statistics

Threads
1,224,837
Messages
6,181,255
Members
453,028
Latest member
letswriteafairytale

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