View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Moving cells to another sheet

Good eyes!

Thanks for the correction.

Rowan Drummond wrote:

Dave copied the typo from your original code that offsets to the right
rather than down. Try:

Sub DRMO()
Dim toWks As Worksheet
Dim actWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim iRow As Long
Dim DestCell As Range

Set actWks = ActiveSheet
Set toWks = Worksheets("DRMO")

Set myRng = Intersect(Selection.EntireRow, actWks.Range("a:a"))

With toWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

With toWks
For Each myCell In myRng.Cells
iRow = myCell.Row
DestCell.Value = actWks.Cells(iRow, "a").Value
DestCell.Offset(0, 4).Value = actWks.Cells(iRow, "BW").Value
DestCell.Offset(0, 8).Value = actWks.Cells(iRow, "AA").Value
Set DestCell = DestCell.Offset(1, 0) '<<<changed
Application.Goto .Range("a1"), scroll:=True
Next myCell
End With
End Sub

Hope this helps
Rowan

Optitron wrote:
With what you gave me it moves column A to column A, and column AA to I,
but not BW to E. Also when I try to select more than one row it takes
one row and then the next row goes on the next row but over a few
cells.
Is there maybe a simpler way? I just want to select a few rows, click
a button and have certain cells in that row moved to the other sheet.



--

Dave Peterson