Consulting

Results 1 to 3 of 3

Thread: Delete cell range not whole row

  1. #1
    VBAX Regular
    Joined
    May 2011
    Posts
    28
    Location

    Delete cell range not whole row

    i want to delete range that i copy and paste it in other sheet but i want to delete the range not the rows, when i write the delete sentence it run the whole code for the half of data and other not , i don't know where is the mistak in my code.
    HTML Code:
    Dim iRow As Long
    For iRow = 1 To 10000
        If Cells(iRow, "E").Value = "1" Then
            Range(Cells(iRow, 2), Cells(iRow, 4)).Copy
            NextRow = iRow + 3
            Sheet9.Cells(NextRow, 2).PasteSpecial xlPasteValues
         Range(Cells(iRow, 2), Cells(iRow, 5)).Delete Shift:=xlUp
    End If
        
    Next iRow

  2. #2
    VBAX Regular
    Joined
    Oct 2010
    Posts
    73
    Location
    Hi, This was ask here. http://www.excelforum.com/excel-prog...-not-rows.html Please do not double post unless you refer to the post in another forum.
    My Time is valuable. The forum's time is valuable.
    So take time to say "Thanks"

    As with all programs there may be an easier way!
    CharlesH

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Since you're likely to want to retain the order things appear in on Sheet9. then don't delete anything in the loop, just copy stuff, then do a second loop to delete stuff, but go up the list, not down it with:
    For irow = 10000 to 1 step -1
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •