Copy rows from one sheet to another based on cell value

craigg3

Board Regular
Joined
Dec 23, 2002
Messages
161
Office Version
  1. 2013
Platform
  1. Windows
I need to copy and paste rows from one sheet to another if the cell value in column B = Bills

Starting on sheet ("iState") at B3, if the cell = Bills, then I need it to copy that whole row to sheet("iSummary") starting on row 3

and then I need it to move to B4 and copy and paste f that cell value = Bill...

and continue until it gets to the end of iState sheet which will usually be about 250 records give or take. I played around with some code but wasn't getting anywhere with what I had. Thanks.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try:
Code:
Sub CopyRow()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim x As Long
    x = 3
    Dim rng As Range
    For Each rng In Sheets("iState").Range("B3:B" & LastRow)
        If rng = "Bills" Then
            rng.EntireRow.Copy Sheets("iSummary").Cells(x, 1)
            x = x + 1
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try:
Code:
Sub CopyRow()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim x As Long
    x = 3
    Dim rng As Range
    For Each rng In Sheets("iState").Range("B3:B" & LastRow)
        If rng = "Bills" Then
            rng.EntireRow.Copy Sheets("iSummary").Cells(x, 1)
            x = x + 1
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub

Thanks, code works great. Is there a way to make it paste only the values and not the formulas within the copied cells?
 
Upvote 0
Try:
Code:
Sub CopyRow()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim x As Long
    x = 3
    Dim rng As Range
    For Each rng In Sheets("iState").Range("B3:B" & LastRow)
        If rng = "Bills" Then
            rng.EntireRow.Copy
            Sheets("iSummary").Cells(x, 1).PasteSpecial xlPasteValues
            x = x + 1
        End If
    Next rng
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try:
Code:
Sub CopyRow()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim x As Long
    x = 3
    Dim rng As Range
    For Each rng In Sheets("iState").Range("B3:B" & LastRow)
        If rng = "Bills" Then
            rng.EntireRow.Copy
            Sheets("iSummary").Cells(x, 1).PasteSpecial xlPasteValues
            x = x + 1
        End If
    Next rng
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub

Works great, thanks again for the help!
 
Upvote 0
Try:
Code:
Sub CopyRow()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim x As Long
    x = 3
    Dim rng As Range
    For Each rng In Sheets("iState").Range("B3:B" & LastRow)
        If rng = "Bills" Then
            rng.EntireRow.Copy
            Sheets("iSummary").Cells(x, 1).PasteSpecial xlPasteValues
            x = x + 1
        End If
    Next rng
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
Hi Mummps
I need this coding, but little different
I want if condition true then the entire row should be copied into a specific sheet of an other excel file
is it possible please guide me thanks
 
Upvote 0
I want if condition true then the entire row should be copied into a specific sheet of an other excel file
What condition needs to be true and what are the names of the specific sheet and other Excel file? Please explain in detail referring to specific cells, rows, columns and sheets.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top