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: 8

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,172
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
 

SlyFoxes

New Member
Joined
Apr 26, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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!
 

vw412

Active Member
Joined
Dec 16, 2011
Messages
343
Office Version
  1. 2019
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
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?
 

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,172
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
 

Watch MrExcel Video

Forum statistics

Threads
1,132,706
Messages
5,654,841
Members
418,155
Latest member
demasisi

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
Top