VBA splitting column to a second file

JOhnG2

New Member
Joined
Nov 25, 2015
Messages
9
Hi all,
I'm new to VBA and i'm really stuck. Any help is much appreciated.
I'm trying to compare two columns in 2 separate files and split one of them into two files.

"Trained" is a worksheet of all those trained in a procedure (both historical and currently employed).
"Employed" is a worksheet of all those currently employed in the company (trained & not trained).

I want to to end up with a worksheet "current and trained", and another called "historical and trained".

I can compare "Employed" with "Trained".

My logic is:
if name from "Employed" is in "Trained" leave it there (this will be renamed my "current and trained" file).
else move to "historical and trained" (already created)

I'm having difficulty with the If else statements. My compare sub is below. Any help would be great.

Sub CompareDel()
Dim Range1 As Range, Range2 As Range, rng1 As Range, rng2 As Range, outRng As Range
Set Range1 = Application.Selection
Set Range1 = Application.InputBox("Range1 :", Type:=8)
Set Range2 = Application.InputBox("Range2:", Type:=8)
Application.ScreenUpdating = False
For Each rng1 In Range1
xValue = rng1.Value
For Each rng2 In Range2
If xValue = rng2.Value Then
If outRng Is Nothing Then
Set outRng = rng1
Else
Set outRng = Application.Union(outRng, rng1)
End If
End If
Next
Next

'I think the If statements should go here but i'm not sure


End Sub
 

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,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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