Copying rows from one sheet to another sheet based on different input in Column B

Firefightersteve

New Member
Joined
Nov 11, 2018
Messages
1
Hello all, I am not a programmer and I am really struggling getting my Excel workbook to do something that has been very simple in google sheets with query formulas. I am currently gathering data daily with a Google Form into a Google Sheet for daily vehicle checks. I am wanting to be able to periodically copy and paste data from my Google Sheet to my Excel workbook that will be accessed by different people. I will manually copy and past the data from Google Sheets to Excel as needed.

Where I am struggling is being able to sort the data in Excel from the "Master" sheet that I am copying and pasting to, to individual sheets based on vehicle numbers. On my "Master" sheet Column B is the Vehicle Number Column and will contain one of my 11 vehicle specific numbers. So if my "Master" sheet has 301 in Column B, then I want that entire row to copy to a new sheet named "301" My Master sheet has a lot of data, I am doing a minimum of 11 vehicle checks per day and the information that I am gathering uses roughly 200 columns (A-HO) although many cells in a row may be blank because not every column pertains to each vehicle.

My different vehicle numbers are 301, 302, 304, 307, 8121, 8171, 8151, 8115, 8101, 8122, and HM15. So my workbook should I believe have 12 separate sheets, "Master" and one for each vehicles. I found a formula in about 10 minutes for Google Sheets and everything that I find for Excel is Macros or VBA which do not make any sense to me.

Any help would be greatly appreciated!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Providing that your master sheet will have consecutive data down column B, and that it will exactly match 1 of the 11 other sheet names (Vehicles), the following macro will do as you require.
I have assumed that each of your sheet has headers in Row 1 and that you do not require the information to remain on the Master sheet once it is on the vehicle sheets.
If that's the case, you could add a button/shape in cell A1 of your master sheet, and assign the following macro to it.

The Macro simply runs through each row of column B from row to to the last row of data,
Cuts the row and pastes it into the next available blank row on the sheet with the same value that is in Column B

There are plenty of tutorials on youtube for installing and using macros, and assigning buttons, but ask here if you really get stuck or are completely lost.


Code:
Sub VehSort()On Error Resume Next
Dim LRmaster As Long, i As Integer, Choice As String, shtChoice As String


Application.ScreenUpdating = False


LRmaster = Sheets("Master").Cells(Rows.Count, "B").End(xlUp).Row


For i = 2 To LRmaster
    shtChoice = Cells(i, 2).Value
    Choice = "LR" & shtChoice
    Choice = Sheets(shtChoice).Cells(Rows.Count, "B").End(xlUp).Row
    Sheets("Master").Cells(i, 2).EntireRow.Cut Sheets(shtChoice).Cells(Choice + 1, 1)
    Choice = Choice + 1
Next i


Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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