Help! Can't get macro to work

zbell

New Member
Joined
Oct 5, 2017
Messages
2
I'm just learning macros in excel and I can't seem to get a certain macro to work. I have one sheet named "Master" that has all the data for the macro on it (donor and proposal information). Column A contains several campaigns in which this donor information is linked to. I would like the macro to pull the rows associated Campaigns in column A and place them on separate sheets (a separate sheet for each campaign). Thank you and I appreciate any help! This is the code I code I've created (with help from internet) and can't seem to get working.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("A:A")) Is Nothing Then Exit Sub

If Target.Value = "Corporate" Then
Range(Range("A:A" & Target.Row)).Copy _
Sheets("Corporate").Range("A:A" & Rows.Count).End(xlUp).Offset(1, 0)

ElseIf Target.Value = "Individual" Then
Range(Range("A:A" & Target.Row)).Copy _
Sheets("Individual").Range("A:A" & Rows.Count).End(xlUp).Offset(1, 0)

End If

End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
To clarify, my end goal is to drop updated data into the "Master" sheet, then have all the sheets in this workbook update automatically so that I don't have to create a separate document for each campaign every time I need to run these reports. I might be totally off-track here and making this more complicated than it needs to be by not using VLookup, idk.
 
Upvote 0
Without knowing what your end goal really is.... I'm thinking just filter Master column A.

If you really need those other sheets, using Worksheet_Change you'll probably need to adjust it to be looking at the range of data on the row to know if it is ready to be copied to the other sheets.

Can you define what "drop updated data into the Master sheet means and how that's done ?
 
Upvote 0
Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Columns("A:A")) Is Nothing Then Exit Sub
    If Target.Value = "Corporate" Then
        Target.EntireRow.Copy Sheets("Corporate").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    ElseIf Target.Value = "Individual" Then
        Target.EntireRow.Copy Sheets("Individual").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    End If
End Sub
When you enter the word "Corporate" or the word "Individual" in column A and exit the cell, that row will be automatically copied into the appropriate sheet.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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