Dear Community,
See Attached File.
I have Jindon's code for "Sorting", but I'm trying to Loop through each column list, copy&pasting into Jindon's code for "Sorting".
Why does Version1() macro work 100% fine (but takes 3 seconds per loop), but Version2() macro does not work at all, and gets poopy results?
Sub version1()
'
' this loops through using Jindon's "Test" Macro
'
Dim count As Integer
count = 0
Do While count < 4 'looping through the first 4 columns as test, eventually want 16,000 columns
Sheets("Sheet2").Activate
ActiveSheet.Range("B2:B31").Offset(0, count).Select 'For B2:B31 it is a range everytime it loops, it offsets by 1 column
Selection.Copy 'Copying Arf range from Sheet 2
Sheets("Sheet1").Activate
ActiveSheet.Range("A2").Select
ActiveSheet.Paste 'Pasting into Jindon's code on Sheet 1
Call test 'This Activates Jindon's Code
ActiveSheet.Range("A2:A31").Select
Selection.Copy 'Copying results of sorted column from Sheet 1
Sheets("Sheet2").Activate
ActiveSheet.Range("B2:B31").Offset(0, count).Select 'Pasting results into Sheet 2
ActiveSheet.Paste
Selection.Copy
count = count + 1
Loop
End Sub
Trying to OPTIMIZE with Version2()
Sub version2()
'
' this loops through using Jindon's "Test" Macro
'
Dim count As Integer
count = 0
Do While count < 4 'looping through the first 4 columns as test, eventually want 16,000 columns
Sheet1.Range("A2:A31") = Sheet2.Range("arf").Offset(0, count).Value
Call test
Sheet2.Range("arf").Offset(0, count) = Sheet1.Range("A2:A31").Value
count = count + 1
Loop
End Sub
I'm trying to Optimize the Version1() macro to eliminate any inefficiency, such as elimianting copy&paste, because I calculate it may take 26 hours to do 16,000 loops at 3 seconds each.
Bookmarks