goldenvision
Board Regular
- Joined
- Jan 13, 2004
- Messages
- 234
I am having problems with the below code. It runs fine but after about 1000 records the spreadsheet disappears and I get a plain white screen until it finishes and then excel appears again.
I suspect it has something to do with the amount of resource is requires.
Any clues how I can streamline the code?
I suspect it has something to do with the amount of resource is requires.
Any clues how I can streamline the code?
Code:
Sub SplitByManuf()
Dim rowcount As Integer
Dim cAV, cBF, cBR, cCA, cCO, cCR, cCU, cDU, cEN, cFE, cFI, cGE, cGO, cHA, cKL, cKU, cLA, cMA, cMD, cMX, cMI, cNA, cPI, cRI, cSE, cST, cTR, cUN, cVR, cYO As Integer
Dim PctDone As Integer
Application.ScreenUpdating = False
Sheets("(Mis)Match").Select
'specify start point
rowcount = 1
cAV = 2
cBF = 2
cBR = 2
cCA = 2
cCO = 2
cCR = 2
cCU = 2
cDU = 2
cEN = 2
cFE = 2
cFI = 2
cGE = 2
cGO = 2
cHA = 2
cKL = 2
cKU = 2
cLA = 2
cMA = 2
cMD = 2
cMX = 2
cMI = 2
cNA = 2
cPI = 2
cRI = 2
cSE = 2
cST = 2
cTR = 2
cUN = 2
cVR = 2
cYO = 2
Do Until Cells(rowcount, 1) = ""
Select Case Cells(rowcount, 8).Value
Case "AV"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("AV").Select
Range("A" & cAV).Select
ActiveSheet.Paste
Range("A1").Select
cAV = cAV + 1
Sheets("(Mis)Match").Select
Case "BF"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("BF").Select
Range("A" & cBF).Select
ActiveSheet.Paste
Range("A1").Select
cBF = cBF + 1
Sheets("(Mis)Match").Select
Case "BR"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("BR").Select
Range("A" & cBR).Select
ActiveSheet.Paste
Range("A1").Select
cBR = cBR + 1
Sheets("(Mis)Match").Select
Case "CA"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("CA").Select
Range("A" & cCA).Select
ActiveSheet.Paste
Range("A1").Select
cCA = cCA + 1
Sheets("(Mis)Match").Select
Case "CO"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("CO").Select
Range("A" & cCO).Select
ActiveSheet.Paste
Range("A1").Select
cCO = cCO + 1
Sheets("(Mis)Match").Select
Case "CR"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("CR").Select
Range("A" & cCR).Select
ActiveSheet.Paste
Range("A1").Select
cCR = cCR + 1
Sheets("(Mis)Match").Select
Case "CU"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("CU").Select
Range("A" & cCU).Select
ActiveSheet.Paste
Range("A1").Select
cCU = cCU + 1
Sheets("(Mis)Match").Select
Case "DU"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("DU").Select
Range("A" & cDU).Select
ActiveSheet.Paste
Range("A1").Select
cDU = cDU + 1
Sheets("(Mis)Match").Select
Case "EN"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("EN").Select
Range("A" & cEN).Select
ActiveSheet.Paste
Range("A1").Select
cEN = cEN + 1
Sheets("(Mis)Match").Select
Case "FE"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("FE").Select
Range("A" & cFE).Select
ActiveSheet.Paste
Range("A1").Select
cFE = cFE + 1
Sheets("(Mis)Match").Select
Case "FI"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("FI").Select
Range("A" & cFI).Select
ActiveSheet.Paste
Range("A1").Select
cFI = cFI + 1
Sheets("(Mis)Match").Select
Case "GE"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("GE").Select
Range("A" & cGE).Select
ActiveSheet.Paste
Range("A1").Select
cGE = cGE + 1
Sheets("(Mis)Match").Select
Case "GO"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("GO").Select
Range("A" & cGO).Select
ActiveSheet.Paste
Range("A1").Select
cGO = cGO + 1
Sheets("(Mis)Match").Select
Case "HA"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("HA").Select
Range("A" & cHA).Select
ActiveSheet.Paste
Range("A1").Select
cHA = cHA + 1
Sheets("(Mis)Match").Select
Case "KL"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("KL").Select
Range("A" & cKL).Select
ActiveSheet.Paste
Range("A1").Select
cKL = cKL + 1
Sheets("(Mis)Match").Select
Case "KU"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("KU").Select
Range("A" & cKU).Select
ActiveSheet.Paste
Range("A1").Select
cKU = cKU + 1
Sheets("(Mis)Match").Select
Case "LA"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("LA").Select
Range("A" & cLA).Select
ActiveSheet.Paste
Range("A1").Select
cLA = cLA + 1
Sheets("(Mis)Match").Select
Case "MA"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("MA").Select
Range("A" & cMA).Select
ActiveSheet.Paste
Range("A1").Select
cMA = cMA + 1
Sheets("(Mis)Match").Select
Case "MD"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("MD").Select
Range("A" & cMD).Select
ActiveSheet.Paste
Range("A1").Select
cMD = cMD + 1
Sheets("(Mis)Match").Select
Case "MX"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("MX").Select
Range("A" & cMX).Select
ActiveSheet.Paste
Range("A1").Select
cMX = cMX + 1
Sheets("(Mis)Match").Select
Case "MI"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("MI").Select
Range("A" & cMI).Select
ActiveSheet.Paste
Range("A1").Select
cMI = cMI + 1
Sheets("(Mis)Match").Select
Case "NA"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("NA").Select
Range("A" & cNA).Select
ActiveSheet.Paste
Range("A1").Select
cNA = cNA + 1
Sheets("(Mis)Match").Select
Case "PI"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("PI").Select
Range("A" & cPI).Select
ActiveSheet.Paste
Range("A1").Select
cPI = cPI + 1
Sheets("(Mis)Match").Select
Case "RI"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("RI").Select
Range("A" & cRI).Select
ActiveSheet.Paste
Range("A1").Select
cRI = cRI + 1
Sheets("(Mis)Match").Select
Case "SE"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("SE").Select
Range("A" & cSE).Select
ActiveSheet.Paste
Range("A1").Select
cSE = cSE + 1
Sheets("(Mis)Match").Select
Case "ST"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("ST").Select
Range("A" & cST).Select
ActiveSheet.Paste
Range("A1").Select
cST = cST + 1
Sheets("(Mis)Match").Select
Case "TR"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("TR").Select
Range("A" & cTR).Select
ActiveSheet.Paste
Range("A1").Select
cTR = cTR + 1
Sheets("(Mis)Match").Select
Case "UN"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("UN").Select
Range("A" & cUN).Select
ActiveSheet.Paste
Range("A1").Select
cUN = cUN + 1
Sheets("(Mis)Match").Select
Case "VR"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("VR").Select
Range("A" & cVR).Select
ActiveSheet.Paste
Range("A1").Select
cVR = cVR + 1
Sheets("(Mis)Match").Select
Case "YO"
Rows(rowcount & ":" & rowcount).Select
Selection.Copy
Sheets("YO").Select
Range("A" & cYO).Select
ActiveSheet.Paste
Range("A1").Select
cYO = cYO + 1
Sheets("(Mis)Match").Select
Case Else
End Select
rowcount = rowcount + 1
'PctDone = rowcount / 8049 * 100
Application.StatusBar = "Processed " & rowcount & "of 8150 Records"
Loop
Application.StatusBar = False
End Sub