ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Additions&Removals (https://www.excelbanter.com/excel-programming/318442-additions-removals.html)

Teresa

Additions&Removals
 
Hi,

I have a situation:
In Sheet 1
I have 3 columns(A,B,C)

Job Number Job Name Client
111 abc Micro
112 gfg Donc
113 fsdfsd Nissan

In sheet 2
I have 1 column (A)

Job Number
111
113
114
115

I am writing a macro which will take each job Number in Sheet1, search in
Sheet 2
and identify additions(112) and Removals (114,115)

and then copy the details (Job Number, Job Name, Client)
to Sheet 3

I think my macro is missing a couple of key lines:

Sub dev()
Dim i
For i = 1 To 10
If Worksheets("Sheet1").Cells(i, 1) = Worksheets("Sheet2").Cells(j, 1) Then
Cells(i, 1).Copy Destination:=Worksheets("Sheet3").Range("A1")

End Sub



gocush[_28_]

Additions&Removals
 
In both cases you are taking items in one list and looking to see if they are
"Not included" in another list.

Does this help get you started:
http://www.wopr.com/cgi-bin/w3t/show...c=1#Post430586



"teresa" wrote:

Hi,

I have a situation:
In Sheet 1
I have 3 columns(A,B,C)

Job Number Job Name Client
111 abc Micro
112 gfg Donc
113 fsdfsd Nissan

In sheet 2
I have 1 column (A)

Job Number
111
113
114
115

I am writing a macro which will take each job Number in Sheet1, search in
Sheet 2
and identify additions(112) and Removals (114,115)

and then copy the details (Job Number, Job Name, Client)
to Sheet 3

I think my macro is missing a couple of key lines:

Sub dev()
Dim i
For i = 1 To 10
If Worksheets("Sheet1").Cells(i, 1) = Worksheets("Sheet2").Cells(j, 1) Then
Cells(i, 1).Copy Destination:=Worksheets("Sheet3").Range("A1")

End Sub



Bob Phillips[_6_]

Additions&Removals
 
Sub dev()
Dim i, j, cLastRow
For i = 1 To 10
With Worksheets("Sheet3")
cLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
If cLastRow = 1 And .Cells(cLastRow, "A").Value < "" Then
cLastRow = cLastRow + 1
For j = 1 To Worksheets("Sheet2").Cells(Rows.Count,
"A").End(xlUp).Row
If Worksheets("Sheet1").Cells(i, 1) =
Worksheets("Sheet2").Cells(j, 1) Then
Worksheets("Sheet1").Cells(i, 1).EntireRow.Copy
Destination:=.Range("A" & cLastRow)
Exit For
End If
Next j
End With
Next i
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"teresa" wrote in message
...
Hi,

I have a situation:
In Sheet 1
I have 3 columns(A,B,C)

Job Number Job Name Client
111 abc Micro
112 gfg Donc
113 fsdfsd Nissan

In sheet 2
I have 1 column (A)

Job Number
111
113
114
115

I am writing a macro which will take each job Number in Sheet1, search in
Sheet 2
and identify additions(112) and Removals (114,115)

and then copy the details (Job Number, Job Name, Client)
to Sheet 3

I think my macro is missing a couple of key lines:

Sub dev()
Dim i
For i = 1 To 10
If Worksheets("Sheet1").Cells(i, 1) = Worksheets("Sheet2").Cells(j, 1)

Then
Cells(i, 1).Copy Destination:=Worksheets("Sheet3").Range("A1")

End Sub






All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com