+ Reply to Thread
Results 1 to 4 of 4

Sort by Cell Value?

Hybrid View

  1. #1
    dan
    Guest

    Re: Sort by Cell Value?

    Thank you! That worked great! However, when I tried to run it on a
    different spreadsheet it didnt work. I got an error saying 'Subscript
    Out of Range'.

    The only difference is if it says Retail in column H I want it to check
    column L to see if something is in it or not. What could the problem
    be? I am using the code below.

    Thanks!!!!

    For Each rCell4 In
    Worksheets("Sheet1").UsedRange.Columns("H").Cells
    If rCell4.Value = "Retail" Then
    If rCell4.Offset(0, 4).Value = "" Then
    rCell4.EntireRow.Copy Worksheets( _
    "Retail NoProj").Cells(Rows.Count, 1).End( _
    xlUp).Offset(1, 0)
    Else
    rCell4.EntireRow.Copy Worksheets( _
    "Retail Proj").Cells(Rows.Count, 1).End( _
    xlUp).Offset(1, 0)
    End If
    End If
    Next rCell4


  2. #2
    Tom Ogilvy
    Guest

    Re: Sort by Cell Value?

    Subscript out of range usually means one of the sheet names in your code
    doesn't exist.

    --
    Regards,
    Tom Ogilvy


    "dan" wrote:

    > Thank you! That worked great! However, when I tried to run it on a
    > different spreadsheet it didnt work. I got an error saying 'Subscript
    > Out of Range'.
    >
    > The only difference is if it says Retail in column H I want it to check
    > column L to see if something is in it or not. What could the problem
    > be? I am using the code below.
    >
    > Thanks!!!!
    >
    > For Each rCell4 In
    > Worksheets("Sheet1").UsedRange.Columns("H").Cells
    > If rCell4.Value = "Retail" Then
    > If rCell4.Offset(0, 4).Value = "" Then
    > rCell4.EntireRow.Copy Worksheets( _
    > "Retail NoProj").Cells(Rows.Count, 1).End( _
    > xlUp).Offset(1, 0)
    > Else
    > rCell4.EntireRow.Copy Worksheets( _
    > "Retail Proj").Cells(Rows.Count, 1).End( _
    > xlUp).Offset(1, 0)
    > End If
    > End If
    > Next rCell4
    >
    >


+ Reply to Thread

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