Excel 2007 Macro Copying Row from Main Sheet to Subsheets based on dropdown selection

melanie13green

New Member
Joined
Sep 21, 2017
Messages
1
I'm not good at coding! Please help me. I have a start but it's not correct.:confused::confused: This is what I would like to do:
On the main sheet I have a drop down menu in the first column, I can select "Prospect" "Team" or "Customer"
The four spreadsheets I have are titled "Main" "Prospects" "Team" Customers"
I have all the contact info for the person after the drop down menu, so let's say I have a "team" member named Melanie then the next column I put the email address, then the next column I put the email, then the street address, city, state, zip, phone number, notes.

I categorize my contacts into these three categories and would like the info to translate to the three sub spreadsheets for easy organization. I don't want the "main" page to delete the info, maybe my "customer" turns into a person on my "team"

Here's what I've tried:

Sub Spreadsheet()


Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim shSource As Worksheet
Dim shTarget1 As Worksheet
Dim shTarget2 As Worksheet
Dim shTarget3 As Worksheet


Set shSource = ThisWorkbook.Sheets("Main")
Set shTarget1 = ThisWorkbook.Sheets("Prospects")
Set shTarget2 = ThisWorkbook.Sheets("Team")
Set shTarget2 = ThisWorkbook.Sheets("Customers")


If shTarget1.Cells(2, 1).Value = "" Then
x = 1
Else
x = shTarget1.Cells(2, 1).CurrentRegion.Rows.Count + 1
End If


If shTarget2.Cells(2, 1).Value = "" Then
y = 1
Else
y = shTarget2.Cells(2, 1).CurrentRegion.Rows.Count + 1
End If


i = 1


Do Until shSource.Cells(i, 2) = ""
If shSource.Cells(i, 2).Value = "Prospect" Then
shSource.Rows(i).Copy
shTarget1.Cells(x, 1).PasteSpecial Paste:=xlPasteValues
x = x + 1
GoTo Line1
ElseIf shSource.Cells(i, 2).Value = "Team" Then
shSource.Rows(i).Copy
shTarget2.Cells(y, 1).PasteSpecial Paste:=xlPasteValues
y = y + 1
GoTo Line1
ElseIf shSource.Cells(i, 2).Value = "Customer" Then
shSource.Rows(i).Copy
shTarget3.Cells(y, 1).PasteSpecial Paste:=xlPasteValues
i = i + 1
GoTo Line1
End If
i = i + 1


Line1: Loop


End Sub

Nothing happens when I press run. I've never written a Macro or ran a macro:eeek:. Any help is super appreciated. Thanks :) -Melanie
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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