Copy data from worksheets based on a cell entry

Sparky

Board Regular
Joined
Feb 18, 2002
Messages
210
Office Version
  1. 2010
Platform
  1. Windows
I have data in a worksheet named Shortages, each entry is preceded with the current date (UK format). What I would like to achieve is to enter a chosen date into cell A1 in a sheet named Review (same workbook) and all entries in the Shortages sheet with the chosen date then copy across into the Review worksheet.

The date in the Shortages sheet appears in column B, I would like the data from column B to column G copied across to the Review sheet.

Hope anyone out there can help with this.

Thanks in advance
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I'm sure this can be done if that's really how you want to go about it, but why not just filter your existing list?
 
Upvote 0
Thanks for the quick reply but filtering is not an option as the data that I require to be copied across WILL contain other information such as part numbers that will be counted via formulas.
 
Upvote 0
Then something like this should work. You'll need to adjust the Ranges to fit your needs. Right-click the sheet tab name and select View Code. In the window that opens, paste the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub '$A$1 IS WHERE I ENTER THE DATE

Dim sh1 As Worksheet, sh2 As Worksheet, LR As Long, TR As Long, PR As Long
Set sh1 = Sheets("Review")  'SHEET WHERE REVIEW INFO WILL BE PASTED
Set sh2 = Sheets("Shortages")  'SHEET WHERE DATA RESIDES
LR2 = sh2.Range("B" & Rows.Count).End(xlUp).Row 'LAST ROW ON SHEET2
PR = 3 'FIRST ROW NUMBER ON SHEET1 WHERE DATA WILL BE PASTED
sh1.Range("A3:F" & Rows.Count).ClearContents 'CLEAR OUT OLD DATA

For Each cell In sh2.Range("B2:B" & LR2).Cells 'STARTS IN ROW 2, ASSUMING HEADERS IN ROW 1
    If cell.Value = Target.Value Then
        TR = cell.Row
        sh2.Range("B" & TR & ":G" & TR).Copy
        sh1.Range("A" & PR).PasteSpecial (xlPasteAll)
        PR = PR + 1 'MOVE TO NEXT PASTE ROW
    End If
Next cell

End Sub
 
Last edited:
Upvote 0
Nogslaw

Thanks for your time spent on this thread it works fine. I will try it in work tomorrow.

Once again thank you.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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