Results 1 to 23 of 23

Select Case and Delete rows

Threaded View

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Select Case and Delete rows

    I need some help fixing my errors. I am trying to automate a repetitive daily task.

    At present, a vlookup is used in column J to return values from another sheet, then column J is used as the basis for further actions to be done.
    For example, some rows are deleted based on the text shown in column J, and some cells in column I have the corresponding value in Column J pasted into them.

    I want to perform both these tasks using a macro.

    If it makes a difference - the values in column J are always vlookup formula results, rather than the text values which are shown in the sample file.

    Sub del()
    Dim lrow As Long
    Dim xrow As Long
    Dim i As Long
    Dim y As Long
    
    ' Here I am trying to delete any row where column J has a text string starting with "Delete row -"
    lrow = Cells(Rows.Count, "J").End(xlUp).Row
    For xrow = lrow To 3 Step -1
        If Range("J" & xrow).Value = "Delete row-*" Then Rows(xrow).Delete
    Next xrow
    
    ' Here I am trying to copy and paste from column J to column I , whenever the value in column J is between "CWA000000" To "CWA999999"
    y = Cells(Rows.Count, "J").End(xlUp).Row
       For i = 2 To y
           Select Case Cells(i, 1).Value
                Case "CWA000000" To "CWA999999"
     Range("I1").Value = Range("J1").Value
                Case Else
            End Select
        Next i
    
     End Sub
    Thanks for your help
    Attached Files Attached Files
    Last edited by labrooy; 12-21-2011 at 05:30 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1