jackeroo75
Technical User
I query the data from our database and copied it to Excel. I compare the sheet and if it matches then copies it to another column. It takes forever to do this. Is there a better way of programming this? Should I store it an array?? help..
For k = (g_startRow + 1) To (endofRow - 1) 'Get range
stringlength = Len(Cells(k, 1).Value) 'Get string's length
If Left(Cells(k, 1).Value, 2) Like "49*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Cells(k, 1).Value Like "WAIT/WR" Then
Cells(k, 26).Value = "ZZ"
Cells(k, 27).Value = "ZZ"
ElseIf Left(Cells(k, 1).Value, 2) Like "4-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "R*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "1-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "3-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "11*" Then
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 2))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "10*" Then
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 2))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
Else
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 1))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
End If
Next k
For k = (g_startRow + 1) To (endofRow - 1) 'Get range
stringlength = Len(Cells(k, 1).Value) 'Get string's length
If Left(Cells(k, 1).Value, 2) Like "49*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Cells(k, 1).Value Like "WAIT/WR" Then
Cells(k, 26).Value = "ZZ"
Cells(k, 27).Value = "ZZ"
ElseIf Left(Cells(k, 1).Value, 2) Like "4-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "R*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "1-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "3-*" Then
Cells(k, 26).Value = Left(Cells(k, 1).Value, 2)
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "11*" Then
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 2))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
ElseIf Left(Cells(k, 1).Value, 2) Like "10*" Then
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 2))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
Else
Cells(k, 26).Value = Val(Left(Cells(k, 1).Value, 1))
Cells(k, 27).Value = Left(Cells(k, 1).Value, stringlength)
End If
Next k