C
Ctech
Hi,
I've new to this VBA stuff, however with my limited knowledge have I
made a macro which adds cells and delete cells depeding on the text in
the first cell of the row.
My main problem is that it takes ages, as my spreadsheet have 25.000
rows.
I guess it would become quicker if I sorted all rows on the first cell,
then marked all rows including "AP" in first cell and then add the cell
needed.
Would it be possible to get this macro time down to a minute or two
instead of 60+ which is it now.
Thanks guys.
The macro:
Sub IfLetterThen()
Application.ScreenUpdating = False
For i = 1 To 100
If IsEmpty(ActiveCell) = False Then
' 2003
If ActiveCell = "AP" Then
ActiveCell.Offset(0, 14).Range("A1").Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -14).Range("A1").Select
ElseIf ActiveCell = "GL" Then
ActiveCell.Offset(0, 12).Range("A1").Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -12).Range("A1").Select
End If
End If
ActiveCell.Offset(1, 0).Select
Next i
Application.ScreenUpdating = True
End Sub
I've new to this VBA stuff, however with my limited knowledge have I
made a macro which adds cells and delete cells depeding on the text in
the first cell of the row.
My main problem is that it takes ages, as my spreadsheet have 25.000
rows.
I guess it would become quicker if I sorted all rows on the first cell,
then marked all rows including "AP" in first cell and then add the cell
needed.
Would it be possible to get this macro time down to a minute or two
instead of 60+ which is it now.
Thanks guys.
The macro:
Sub IfLetterThen()
Application.ScreenUpdating = False
For i = 1 To 100
If IsEmpty(ActiveCell) = False Then
' 2003
If ActiveCell = "AP" Then
ActiveCell.Offset(0, 14).Range("A1").Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -14).Range("A1").Select
ElseIf ActiveCell = "GL" Then
ActiveCell.Offset(0, 12).Range("A1").Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, -12).Range("A1").Select
End If
End If
ActiveCell.Offset(1, 0).Select
Next i
Application.ScreenUpdating = True
End Sub