What is the best way to do this?

htchandler

New Member
Joined
Apr 17, 2011
Messages
47
Rows are each individual, Columns are information about each individual. In one of those column's I'm going to have a drop down menu to select "Present", "Absent", "Training", etc. When you select any one of these I want something to cause some of that individual's information to be copied over to a seperate tab to build a roster of all those that are "Present", "Absent", etc. What do I use to cause each individual's information to be copied to a seperate tab?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This can be done using VBA event code. Which column will the data validation be in?
 
Upvote 0
By data validation do you mean what colum will the drop down be in? If so it will probably not be in the left most column of the spreadsheet. Does it make a difference what column the data validation is in?
 
Upvote 0
For now I think I actually will be placing the status in Column A. Have any good advice for books or training materials for VBA?
 
Upvote 0
This assumes that you have sheets already set up named exactly the same as your drop down list, i.e Present, Training etc.

Right click the tab of your 'master' sheet, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then 'this is for column A, for column E use 5 and so on
Target.EntireRow.Copy Destination:=Sheets(Target.Value).Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub

For learning VBA see Hiker's list http://www.mrexcel.com/forum/showpost.php?p=2676997&postcount=5
 
Upvote 0
I'm receiving an error:

"Block end if without if"

Is there a way I can paste a screen shot of the sheet I'm working with on this forum so you can better see my set up?
 
Upvote 0
It looks like Vog omitted an End If statement. Try this modification to Vog's code to see if it works...

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Column = 1 Then 'this is for column A, for column E use 5 and so on
    Target.EntireRow.Copy Destination:=Sheets(Target.Value).Range("A" & Rows.Count).End(xlUp).Offset(1)
  End If
End Sub
 
Upvote 0
Wow it works. Thank you. There is just a couple of modifications I need now:

I get a run time error if I change the status from anything (e.g. "Present") to blank. I would just like it to remove the individuals name from the roster they were on and let me leave their status blank.

Right now once I make a status selection for a person their name stays on that roster even if I change their status. What do I need to do to the code to make it so if I select "Present", then "Absent" for 1 individual so their name would be pulled off the Present Roster and moved over to the Absent Roster.

Also, what do I need to do to the code so that it only copies the data in rows B, C, D, and F (E is their SSN and I don't need that posted to the roster of each group)

P.s. What do you recommend for somone just learning code for the first time? I've been looking through books all weekend but they all just want to teach me how to make a window pop up that says "Hello World".

Thank you again for the help. This will significantly reduce my offices workload.
 
Upvote 0
To fix the error and copy only columns B,C,D and F try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Value <> "" Then 'this is for column A, for column E use 5 and so on
    Target.Offset(, 1).Resize(, 3).Copy Destination:=Sheets(Target.Value).Range("A" & Rows.Count).End(xlUp).Offset(1)
    Target.Offset(, 5).Copy Destination:=Sheets(Target.Value).Range("D" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub

Pulling a person off one sheet and onto another would be difficult unless they can physically only belong to one sheet at a time. If that is the case then their SSN would be useful as a unique identifier.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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