Consulting

Results 1 to 5 of 5

Thread: Solved: Copy Entire Row based on Cell

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Posts
    20
    Location

    Solved: Copy Entire Row based on Cell

    If I run the following code, it copies over the required data, but only from column F:

    [vba]
    With ThisWorkbook
    ReDim SheetWiseMax(1 To .Sheets.Count)
    For i = 1 To .Sheets.Count
    If Not Sheets(i).Name = "Release 3.0" Or Not Sheets(i).Name = "New Issues" Or Not Sheets(i).Name = "Closed" Or Not Sheets(i).Name = "Deferred" Then
    For Each cell In Sheets(i).Range("F:F")
    If UCase(cell.Value) = "Y" Then
    cell.Resize(, 12).Copy Sheets("HOT").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next cell
    End If
    Next i
    End With
    [/vba]

    I'd like to grab the entire row, starting from column A. I've tried some different things, but I either get errors or nothing copied. I understand that I've set the range to F:F; my goal is to have it check the value in column F set to "Y", and if so, grab that row and copy it over.

  2. #2
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    What happens if you use the full width of the table and test the value in the cell for column F (column 6)?
    Ron
    Windermere, FL

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    With ThisWorkbook
    ReDim SheetWiseMax(1 To .Sheets.Count)
    For i = 1 To .Sheets.Count
    If Not Sheets(i).Name = "Release 3.0" Or Not Sheets(i).Name = "New Issues" Or Not Sheets(i).Name = "Closed" Or Not Sheets(i).Name = "Deferred" Then
    For Each cell In Sheets(i).Range("F:F")
    If UCase(cell.Value) = "Y" Then
    cell.Entirerow.Copy Sheets("HOT").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next cell
    End If
    Next i
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Jun 2007
    Posts
    20
    Location
    cell.entirerow.copy worked. Can you tell I don't know VBA? And this after I looked all over for a good reference to the types of parameters the cell object could take.

    Is there a good reference that would tell me what commands are applicable to various objects, like cell?

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    cell isn't an object, it is a variable that you point at a range obje. Help will give you the properties and methods of an object, such as range.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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