Copying data to another sheet based on criteria

NeedExclHlp

New Member
Joined
Aug 12, 2016
Messages
9
I have two sheets, one called Master and another called IEP. Data is entered into the Master sheet in rows from Column A to Column O.

If Column J has an "X", I would like Column E of the same row to be copied into the next available row in Column A of the IEP sheet. I also want Column F copied into Column B, Column C copied into Column C, and Column D copied into Column D.

I hope this makes sense. Any tips or suggestions would be greatly appreciated.

Thanks you.
 
Since you say sometimes you may want to choose multiple sheets to copy row to we need another approach.
Would you consider choosing sheet names from a Activex listbox
The listbox would be populated with sheet names you would select the sheet names. Select a cell in the row you want to copy and then press a button to run the script.
Would something like this work.
 
Upvote 0

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
Yes, that sounds like it would work great. Thank you for your patience. Can you show me the process? Please let me know if you need any more information.
 
Upvote 0
Here is what you will need.
One Activex Listbox Named “Listbox1”
Two Activex Command buttons Named CommandButton1 and CommandButton2

When you click the Commandbutton1 your script will run. Copying the row with the active cell to the sheets you have selected in the listbox.
In the list box you can select more than one sheet names if you want.

In Activex Command button named “CommandButton1”
Put this script:

Code:
Private Sub CommandButton1_Click()
'This script Runs your script
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) Then
            Lastrow = Sheets(ListBox1.List(i)).Cells(Rows.Count, "A").End(xlUp).Row + 1
            Rows(ActiveCell.Row).Copy Destination:=Sheets(ListBox1.List(i)).Rows(Lastrow)
        ListBox1.Selected(i) = False
        
        End If
    Next
End Sub


When you click this Commandbutton2 all your sheet names will be populated into the listbox. You will only need to click this button once unless you add new sheets and want them added to the list.

In Activex Command button named “CommandButton2”
Put this script:

Code:
Private Sub CommandButton2_Click()
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) Then
            Lastrow = Sheets(ListBox1.List(i)).Cells(Rows.Count, "A").End(xlUp).Row + 1
            Rows(ActiveCell.Row).Copy Destination:=Sheets(ListBox1.List(i)).Rows(Lastrow)
        ListBox1.Selected(i) = False
        
        End If
    Next
    
End Sub
 
Last edited:
Upvote 0
One additional thing:

Right click on your listbox1 and:
Select properties and where you see Multiselect choose Multiselect

This will allow you to select more then one item in the listbox.
 
Last edited:
Upvote 0
I messed up.

This script populates the listbox.

Code:
Private Sub CommandButton2_Click()
Dim i As Long
'This script populates the listbox
ListBox1.Clear
    For i = 1 To Sheets.Count
    ListBox1.AddItem Sheets(i).Name
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,193
Messages
6,129,447
Members
449,509
Latest member
ajbooisen

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