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. 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. Any help is super appreciated. Thanks -Melanie
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. Any help is super appreciated. Thanks -Melanie