Move specific data to new sheet based on chosen dropdown name

SlyFoxes

New Member
Joined
Apr 26, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have an Excel file with headers A1-D1
Data is entered in the first three columns and there is a dropdown in the fourth
I need to copy the detail in columns A-C only to a new sheet of the same name as the dropdown in Column D
I have additional headers on the other named sheets for formula so would need only 3 columns of data to be moved so it does not overwrite the formula
Main Sheet is called "All Receipts"
Dropdown Categories (and corresponding sheets) are Progress / Hold / Complete
I would really appreciate any assistance with VBA code to do this
 

Attachments

  • Receipts.PNG
    Receipts.PNG
    20.6 KB · Views: 9

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
try this on a copy of your file.

VBA Code:
Sub do_it()
Dim ws As Worksheet

For r = 2 To Cells(Rows.Count, "D").End(xlUp).Row

sht = Cells(r, "D")
If sht = "Progress" Then Set ws = Worksheets("Progress")
If sht = "Hold" Then Set ws = Worksheets("Hold")
If sht = "Complete" Then Set ws = Worksheets("Complete")


wr = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & wr & ":C" & wr).Value = Range("A" & r & ":C" & r).Value

Next r

End Sub

hth,
Ross
 
Upvote 0
try this on a copy of your file.

VBA Code:
Sub do_it()
Dim ws As Worksheet

For r = 2 To Cells(Rows.Count, "D").End(xlUp).Row

sht = Cells(r, "D")
If sht = "Progress" Then Set ws = Worksheets("Progress")
If sht = "Hold" Then Set ws = Worksheets("Hold")
If sht = "Complete" Then Set ws = Worksheets("Complete")


wr = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Range("A" & wr & ":C" & wr).Value = Range("A" & r & ":C" & r).Value

Next r

End Sub

hth,
Ross
Ross, thank you so much. This worked absolutely perfectly, you are awesome!
 
Upvote 0
what do you see as the trigger to make the copy happen? When copying, should the items be added to the end of the destination sheet?
 
Upvote 0
you welcome and thanks for the feedback.

vw412

the line below references to the end of the destination sheet.

wr = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,513
Members
448,967
Latest member
screechyboy79

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