rnordquest
New member
- Jul 17, 2003
- 148
How can I speed up this section of my macro? I have enough data that this one part takes 45 min. endRow ~ 18,000. It just copies the part number into column A. Original data looks something like this:
Drawing 12345
abc
def
23456 23456
abc
junk
34567 34567
abc
Drawing 45678
=====
For k = 2 To endRow
Cells(k, 1).Activate
curCell = ActiveCell.Value
firstCh = Left(curCell, 1)
If ActiveCell.Value = "Drawing" Then
pn = ActiveCell.Offset(0, 1).Value
ElseIf firstCh = "1" Or _
firstCh = "2" Or _
firstCh = "3" Or _
firstCh = "4" Or _
firstCh = "5" Or _
firstCh = "6" Or _
firstCh = "7" Or _
firstCh = "8" Or _
firstCh = "9" Or _
firstCh = "M" Then
pn = ActiveCell.Value
End If
ActiveCell.Value = pn
Next k
=====
When finished it looks like this:
12345 12345
12345 abc
12345 def
23456 23456
23456 abc
23456
34567 34567
34567 abc
45678 45678
Drawing 12345
abc
def
23456 23456
abc
junk
34567 34567
abc
Drawing 45678
=====
For k = 2 To endRow
Cells(k, 1).Activate
curCell = ActiveCell.Value
firstCh = Left(curCell, 1)
If ActiveCell.Value = "Drawing" Then
pn = ActiveCell.Offset(0, 1).Value
ElseIf firstCh = "1" Or _
firstCh = "2" Or _
firstCh = "3" Or _
firstCh = "4" Or _
firstCh = "5" Or _
firstCh = "6" Or _
firstCh = "7" Or _
firstCh = "8" Or _
firstCh = "9" Or _
firstCh = "M" Then
pn = ActiveCell.Value
End If
ActiveCell.Value = pn
Next k
=====
When finished it looks like this:
12345 12345
12345 abc
12345 def
23456 23456
23456 abc
23456
34567 34567
34567 abc
45678 45678