VBA locate names within range based on criteria, concatenate, copy and paste to another worksheet

waltherk

New Member
Joined
Apr 24, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello, I am new to this forum ( indeed, new to any Excel-forum ) ...

I have a worksheet containing a list of employees ("Employees"), which includes, inter alia; first name (Column B), last name (Column C), job title (Column D) and employee number (Column A). The names are self-explanatory while the (unique) employee numbers are four digits in length (e.g., 0012, 1025, 5000, 8016, etc.). Employees with a number <8000 work in one location, while those with an employee number >=8000 are attributable to another place of business. As we often hire drivers (Column D), the employee worksheet ("Employees") is dynamic.

What I am looking to do is apply Visual Basic so that I can intermittently use the revised "Employees"-worksheet to update a table containing these "drivers" in another worksheet. This second worksheet ("Accidents") contains two lists of drivers, who work in separate locations, Location A and Location B, and are accordingly "tagged" as such with the aforementioned employee number).

So, here is an abbreviated list of my challenges :

FIRSTLY, although I am able to locate the corresponding drivers and location using :

If Worksheets("Employees").Cells(i, 4).Value = "Driver" And Worksheets("Employees").Cells(i, 1).Value < 8000 Then
Worksheets("Employees").Cells(i, 2).Copy

... I am unable to concatenate first and last names, then copy (so that I can subsequently paste these into "Accidents").

SECONDLY, as the list of drivers becomes longer with time, it is, of course, requisite that the VBA-code "count" the number of entries that have been copied and, accordingly, compare this sum to the number of existing rows in the "driver-table" within the "Accidents" sheet and subsequently "add" rows to the driver-table within "Accidents", if necessary.
Furthermore, as the driver-table(s) within "Accidents" have additional columns, I can not simply "add" rows: The VBA-code needs to copy extant rows, including formulae and formatting, yet excluding other entries (i.e., the name and number of accidents per month in any copie rows) prior to pasting/adding these rows. Once inserted, the code will be required to subsequently paste the concatenated, individual drivers. Notwithstanding using an automated sort function once pasted.

That's a lot in one breath. I hope/trust you can follow my train-of-thought.

Better than a thousand days of diligent study is one day with a great (forum).
- Japanese Proverb

Any assistance is highly appreciated.

waltherk
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

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