View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Phrank Phrank is offline
external usenet poster
 
Posts: 153
Default Rearranging columns in a large spreadsheet

Hi, just touching base again. I haven't been able to get back at this
yet, but I will be tonight and this weekend. I'll post back with
results. Thank you!!

On Wed, 17 Jun 2015 08:26:57 +0200, Claus Busch
wrote:

Hi Frank,

Am Tue, 16 Jun 2015 22:44:49 -0400 schrieb Phrank:

I first tried changing the calculation to manual, but that had no
effect. I put the autocalc code in both the main macro and the sub
routine with the same result. Below is the code that gets run that
does indeed work, just very slow (this is part of a 'formatting'
macro, not too much else going on, but a little bit).


you don' t need strCols because your columns will go one by one.
Following code does that in a blink. If it works slow on your machine
the rest of your code causes that issue:

Sub Test()
Dim wksSource As Worksheet
Dim strHeaders As String
Dim varHeaders As Variant
Dim i As Long, c As Range

Set wksSource = Sheets("Sheet1")

Application.ScreenUpdating = False
With wksSource
strHeaders = "Age(Dynamic),ProView,INV#,CMPL#,PI#," _
& "Investigation Assigned to,Investigation State,Op Lvl," & _
"Catalog #,User Notes,System Likely Rationale,My Likely Rationale" _
& ",System Rationale for Internal Testing," & _
"My Rationale for Internal Testing,LastReviewed,Product Long Description"
varHeaders = Split(strHeaders, ",")

For i = UBound(varHeaders) To LBound(varHeaders) Step -1
Set c = Range("1:1").Find(varHeaders(i), , xlValues, xlWhole)
If Not c Is Nothing Then
.Columns(c.Column).Cut
.Columns("A").Insert Shift:=xlToRight
End If
Next
End With 'wksSource
Application.ScreenUpdating = True
End Sub


Regards
Claus B.