Click here to Skip to main content
15,671,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am developing a macro which will first transfer and remove. i am using concatenated fields someone help me ..
Option Explicit

Sub transferorderdata()
Dim wkbor, wkbvl, wkbysd, wkbtr As Workbook
Dim wknm, wknm1, wknm2  As String

wknm2 = "C:\vbproject\tracker\ysdflow2.xlsx"
wknm = "d:\Open.xls" '-------Open order
wknm1 = "d:\tracker.xlsx" '------tracker file
Set wkbor = Workbooks.Open(wknm)
Set wkbtr = Workbooks.Open(wknm1)
Dim irowor, irowtro, irowtrs As Integer
Dim i, j As Integer
Dim selor, seltro As String
Dim blnor As Boolean

'__________________Ordering Compare_________________
irowor = wkbor.Sheets("Filtered").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
irowtro = wkbtr.Sheets("Ordering").Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row

For i = 2 To irowor
For j = 2 To irowtro

  selor = wkbor.Sheets("Filtered").Cells(i, 1).Value + wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 9).Value
'MsgBox selor
seltro = wkbtr.Sheets("ordering").Cells(i, 39).Value

If selor = seltro Then
blnor = True
'MsgBox "value equal "


blnor = False

End If
If blnor = True Then

wkbtr.Sheets("Ordering").Cells(j, 7).Value = wkbor.Sheets("Filtered").Cells(i, 1).Value 'order no
wkbtr.Sheets("Ordering").Cells(j, 2).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 32).Value 'sold to party
wkbtr.Sheets("Ordering").Cells(j, 9).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 13).Value 'plnt
wkbtr.Sheets("Ordering").Cells(j, 8).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 3).Value 'svo
wkbtr.Sheets("Ordering").Cells(j, 10).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 14).Value 'shtpt
wkbtr.Sheets("Ordering").Cells(j, 11).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 38).Value ' username

Exit For

End If

If blnor = False Then
Dim irowtro1 As Integer

irowtro1 = wkbtr.Sheets("Ordering").Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row
wkbtr.Sheets("Ordering").Cells(irowtro1, 39).Value = selor
wkbtr.Sheets("Ordering").Cells(irowtro1, 7).Value = wkbor.Sheets("Filtered").Cells(i, 1).Value 'order no
wkbtr.Sheets("Ordering").Cells(irowtro1, 2).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 32).Value 'sold to party
wkbtr.Sheets("Ordering").Cells(irowtro1, 9).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 13).Value 'plnt
wkbtr.Sheets("Ordering").Cells(irowtro1, 8).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 3).Value 'svo
wkbtr.Sheets("Ordering").Cells(irowtro1, 10).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 14).Value 'shtpt
wkbtr.Sheets("Ordering").Cells(irowtro1, 11).Value = wkbor.Sheets("Filtered").Cells(i, 1).Offset(0, 38).Value ' username

Exit For

End If



 End Sub

it is working but at the end i am left with some duplicates entry in the final file..
some body help me out
Updated 1-Nov-12 20:16pm
Maciej Los 1-Nov-12 14:11pm    
We need example data and its structure...

1 solution

(...) at the end (...) some duplicates entry in the final file..

That's because the count of filled rows in both files is differ. Depends on your conditions, you need to jump out the loop.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900