zombiemaster
Board Regular
- Joined
- Oct 27, 2009
- Messages
- 245
Hoping a second set of eyes can help speed up this VBA.
I created a process where I copy information from one spreadsheet (used by our Contact Center to track call data) and paste it into a "transition sheet" - then I click my button to run my code that moves stuff around, format dates/times into just dates, etc. so I can get it into a format to copy/paste into a third sheet used by my department for processing the calls.
When I just run the macro normally, it takes 3 minutes to finish. It's not that huge of a macro, either, and the dataset is small (less than 25 rows of data each time) so I don't know what is slowing it down. I am hoping someone here can take a look and maybe see something that I'm not. I'm far from an expert, and I know I have some repetition here that could probably be avoided, but that shouldn't slow it down this much. Any help is appreciated!
When I run it a few steps at a time in VBA editor using break/stops, it only takes about 20 seconds to get through it. Something here doesn't seem right to me...lol
Thanks for looking!
-=ZM=-
I created a process where I copy information from one spreadsheet (used by our Contact Center to track call data) and paste it into a "transition sheet" - then I click my button to run my code that moves stuff around, format dates/times into just dates, etc. so I can get it into a format to copy/paste into a third sheet used by my department for processing the calls.
When I just run the macro normally, it takes 3 minutes to finish. It's not that huge of a macro, either, and the dataset is small (less than 25 rows of data each time) so I don't know what is slowing it down. I am hoping someone here can take a look and maybe see something that I'm not. I'm far from an expert, and I know I have some repetition here that could probably be avoided, but that shouldn't slow it down this much. Any help is appreciated!
When I run it a few steps at a time in VBA editor using break/stops, it only takes about 20 seconds to get through it. Something here doesn't seem right to me...lol
Thanks for looking!
-=ZM=-
VBA Code:
Sub Transition()
'
' Fixing the time stamp issues in column B
Range("A65536").Select
Selection.End(xlUp).Select
endRow$ = ActiveCell.Row
Range("B7:B" + endRow$).Select
Dim A As Range
Set A = Selection
For Each cell In A
cell.Value = WorksheetFunction.Trim(cell)
Next
Sheets("To Support Tracking").Visible = True
Sheets("To Support Tracking").Select
Application.ScreenUpdating = False
Range("A65536").Select
Selection.End(xlUp).Select
endRow$ = ActiveCell.Row
Range("A2:F" + endRow$).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H2:S" + endRow$).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
' Sort - "Z to A" to bring actual items to the top of the list so blank rows are ignored
Range("A2:V" + endRow$).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("To Support Tracking").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("To Support Tracking").Sort.SortFields.Add2 Key:= _
Range("I2:I" + endRow$), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("To Support Tracking").Sort
.SetRange Range("A1:V" + endRow$)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select
Application.ScreenUpdating = True
' Gets rid of Time stamp in column A
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 3), Array(2, 9), Array(3, 9)), TrailingMinusNumbers:=True
Selection.NumberFormat = "m/d/yyyy"
Application.Goto Reference:="R2C1"
' Eliminates periods and commas from the Name columns
Application.ScreenUpdating = False
Range("A65536").Select
Selection.End(xlUp).Select
endRow$ = ActiveCell.Row
Range("D2:E" + endRow$).Select
Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.Replace What:=",", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
' Hides the From Contact Center tab:
Sheets("From Contact Center").Visible = False
Range("A2").Select
End Sub