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.
 
Hi mumps
good morning and have a nice day
I have share the both data entry and all data files
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
 
Upvote 0
Depending on your dataset size you could also use
VBA Code:
Sub MM1()
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Range("B3:B" & LastRow)
    .AutoFilter Field:=1, Criteria1:="Bills"
    .SpecialCells(xlVisible).Copy
    Sheets("iSummary").Cells(1, 1).PasteSpecial xlPasteValues
    .AutoFilter
End With
End Sub
 
Upvote 0
Depending on your dataset you could also use
VBA Code:
Sub MM1()
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Range("B3:B" & LastRow)
    .AutoFilter Field:=1, Criteria1:="Bills"
    .SpecialCells(xlVisible).Copy
    Sheets("iSummary").Cells(3, 2).PasteSpecial xlPasteValues
    .AutoFilter
End With
End Sub
 
Upvote 0
Depending on your dataset you could also use
VBA Code:
Sub MM1()
    Dim LastRow As Long
    LastRow = Sheets("iState").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Range("B3:B" & LastRow)
    .AutoFilter Field:=1, Criteria1:="Bills"
    .SpecialCells(xlVisible).Copy
    Sheets("iSummary").Cells(3, 2).PasteSpecial xlPasteValues
    .AutoFilter
End With
End Sub
HI Miachael
thanks for your attention
I need a little change for destination file
i want to copy data into an other file instead of the sheet of same file
for example I am using a file named data entry and if condition true then the entire row should be copied into the specific sheet of other file named All data
 
Upvote 0
Your links to Dropbox bring me to the Login page. I need the link to your files. After you upload the file to Dropbox, mark each file for sharing and you will be given a link to each file that you can post here.
 
Upvote 0
Both files you posted don't have any data so it makes it difficult to test a possible solution. Please attach files with data and explain in detail what you want to do referring to specific cells, rows, columns, sheets and workbooks using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
Both files you posted don't have any data so it makes it difficult to test a possible solution. Please attach files with data and explain in detail what you want to do referring to specific cells, rows, columns, sheets and workbooks using a few examples from your data (de-sensitized if necessary).
hi
good morning and have a nice day
there are two files one of them is data entry 1 in which we enter data (in attached file there are 160+entries but the entries might be about 400 too) in this file in Column G we select nature of emergency from a drop down list.
On the behalf of nature of emergency we want that all data of each emergency should be copied in the other file named All Data. and in All Data file there are 60+ sheets with the name of each nature of emergency.
for example in Data Entry File if we select the nature of emergency RTA (road traffic accident) the entire row should be copied into the RTA Sheet of All Data file and similarly all other emergencies
I hope you will understand
 
Upvote 0

Forum statistics

Threads
1,215,334
Messages
6,124,319
Members
449,153
Latest member
JazzSingerNL

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