How to Auto-populate in different sheets via keyword with a command button

crniess

New Member
Joined
Jun 20, 2017
Messages
7
Hello all. I am an architect and I am trying to develop a code in excel for organizing our projects.

So far I have a workbook with two tabs. Sheet1 is called "Entry", Sheet2 is called "NumericalOrder", Sheet3 is called "Alphabetical Order", and Sheet 4 is called "Civil". The headers on the Entry and Numerical Order sheets is Project #, Project Name, Project Industry, Project Type, and Tracking Sheet across row 1.


I am using a command button so our office manager will enter in the needed information on the Entry sheet under the necessary headers. The command button moves all the information into the NumericalOrder and AlphabeticOrder sheet under the correct headers, sorts the lists correctly, and also clears the info in the Entry sheet. This part I have figured out.

What I'm having toubles with now is that we would like to populate lists by project industry with the click of this command button as well. What this would mean is when entering "Civil" in the Project Industry Column(Column C) , I would like this row of information to be sent to the Civil sheet, but if Residential is typed into that column, I don't want it to go to the Civil sheet.

What do I need to add to my code to get this sorting issue out of my way? I have been watching tutorials on coding for the past two days without having any prior knowledge and I can't find any information to answer my current question!! I hope you all can help


Here is my current working VBA Command Button code:
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Private Sub CommandButton1_Click()
Dim ProjectNumber As String, ProjectName As String, ProjectIndustry As String, ProjectType As String, TrackingSheet As String
Dim nextrow As Long
With Worksheets("Entry")
ProjectNumber = Range("A2")
ProjectName = Range("B2")
ProjectIndustry = Range("C2")
ProjectType = Range("D2")
TrackingSheet = Range("E2")
End With

With Worksheets("NumericalOrder")
nextrow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
.Range("A" & nextrow).Resize(1, 5).Value = Array(ProjectNumber, ProjectName, ProjectIndustry, ProjectType, TrackingSheet)
.Range("A1").CurrentRegion.Sort KEY1:=.[A2], order1:=xlDescending, Header:=xlYes
End With


With Worksheets("AlphabeticalOrder")
nextrow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
.Range("A" & nextrow).Resize(1, 5).Value = Array(ProjectNumber, ProjectName, ProjectIndustry, ProjectType, TrackingSheet)
.Range("A1").CurrentRegion.Sort KEY1:=.[B2], order1:=xlAscending, Header:=xlYes
End With


Worksheets("Entry").Range("A2:E2").ClearContents


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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