View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default this code is VERY slow, is it the code or perhaps a worksheet issue

Try this...

Assumes ColA contains "X" in some rows; Cols B/C contain data that will
be shifted to Cols A/B if colA contains "X". (Modify to suit your
layout)

Sub CopyLeft()
Dim rng As Range, lRow As Long
Const NumRows As Long = 16 '//edit size as required

'Range to be checked is from row1 to resize constant above,
'where the active cell is in row1/column1 of the data to shift.
Set rng = ActiveCell.Resize(NumRows)

For lRow = 1 To rng.Rows.Count
With rng
With .Cells(lRow)
If .Offset(0, -1).Value = "X" Then _
.Resize(1, 2).Cut .Offset(0, -1)
End With '.Cells(lRow)
End With 'rng
Next 'lRow
End Sub 'CopyLeft()

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion