Copy to next available row and sort

B-radK

Board Regular
Joined
Apr 1, 2010
Messages
96
Office Version
  1. 365
Platform
  1. Windows
Hi team,

I have a "workbook1" with a database full of names in sheet 1 and their corresponding information in sheet 2.
I have made a drop-down cell with "Onboard" and "Not onboard" next to each of the names in sheet 1.
When I select "Onboard" I would like that row's contents and the contents of that same row in sheet 2 to be copied.
I would then like to open a workbook called "Onboard" and have the copied information pasted into sheet 1 and sheet 2 in the next blank row and then sort column A in both sheets alphabetically.

I tried recording a macro, but it was really long winded and I'm sure there's a better way.

Is anyone able to help? It would be greatly appreciated.
Thanks so much,
B-radK:)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi team,

I have a "workbook1" with a database full of names in sheet 1 and their corresponding information in sheet 2.
I have made a drop-down cell with "Onboard" and "Not onboard" next to each of the names in sheet 1.
When I select "Onboard" I would like that row's contents and the contents of that same row in sheet 2 to be copied.
I would then like to open a workbook called "Onboard" and have the copied information pasted into sheet 1 and sheet 2 in the next blank row and then sort column A in both sheets alphabetically.

I tried recording a macro, but it was really long winded and I'm sure there's a better way.

Is anyone able to help? It would be greatly appreciated.
Thanks so much,
B-radK:)

Does this help in anyway? Or maybe get you started?

Code:
Sub BradK()
'
Dim lr As Long

    Sheets(Array("Sheet1", "Sheet2")).Select
    Sheets("Sheet1").Activate
    If ActiveCell.Value = "Onboard" Then
    ActiveCell.EntireRow.Select
    End If
    Selection.Copy
    Workbooks.Open Filename:="D:\YOURPATH\Onboard.xls"

lr = Workbooks("OnBoard.xls").Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row + 1

    Range("A" & lr).Select
    ActiveSheet.Paste
    Sheets("Sheet1").Select
    Rows("2:" & lr).Select
    Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
    Sheets("Sheet2").Activate
    Rows("2:" & lr).Select
    Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal



End Sub
 
Upvote 0
Hi John.

Thank you very much mate, that is a great start and I can take it from here.
Thanks again mate, very much appreciated!

Cheers
Brad.
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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