From last post
Before
_____ Workbook: Alert.txt ( Using Excel 2007 32 bit )
Worksheet: Alert
Row\Col A B C D E F G 1NSE 14361 6A 2NSE 25 6A 3NSE 15083 6A 4NSE 17388 6A 5NSE 100 6A 6NSE 22 6A 7
Run macro ( from here https://www.ozgrid.com/forum/index.p...54#post1233954 )check wheather column H of 1.xls is greater or lower than column D of 1.xls
if column H of 1.xls is greater than column D of 1.xls then match column I of 1.xls with column B of 2.csv & if it matches then put this symbol "<" in column D of 2.csv & copy paste the data of column K of 1.xls in column E of 2.csv
or
if column H of 1.xls is lower than column D of 1.xls then match column I of 1.xls with column B of 2.csv & if it matches then put this symbol ">" in column D of 2.csv & copy paste the data of column K of 1.xls in column E of 2.csv
After - results after running macro aboveCode:Sub STEP8() ' http://www.excelfox.com/forum/showthread.php/2461-copy-and-paste-by-vba?p=13126&viewfull=1#post13126 Dim Wb1 As Workbook, Wb2 As Workbook Dim Ws1 As Worksheet, Ws2 As Worksheet Dim rg1 As Range, i As Long, c As Range Set Wb1 = Workbooks("1.xls") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls") Set Wb2 = Workbooks("Alert.txt") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Alert..csv") Set Ws1 = Wb1.Worksheets.Item(1) Set Ws2 = Wb2.Worksheets.Item(1) Set rg1 = Ws1.Cells(1, 1).CurrentRegion With rg1 For i = 2 To rg1.Rows.Count If .Cells(i, 8) > .Cells(i, 4) Then ' if column H of 1.xls is greater than column D of 1.xls Set c = Ws2.Columns(2).Find(.Cells(i, 9)) ' match column I of 1.xls with column B of 2.csv If Not c Is Nothing Then 'if match found c.Offset(, 2).Value = "<" ' put this symbol "<" in column D of 2 c.Offset(, 3).Value = .Cells(i, 11) ' copy paste the data of column K of 1.xls in column E of 2.csv End If Else ' if column H of 1.xls is lower than column D of 1.xls Set c = Ws2.Columns(2).Find(.Cells(i, 9)) ' match column I of 1.xls with column B of 2.csv If Not c Is Nothing Then 'if match found c.Offset(, 2).Value = ">" ' then put this symbol ">" in column D of 2.csv c.Offset(, 3).Value = .Cells(i, 11) ' copy paste the data of column K of 1.xls in column E of 2.csv End If End If Next i End With End Sub
_____ Workbook: Alert.txt ( Using Excel 2007 32 bit )
Worksheet: Alert
Row\Col A B C D E F G 1NSE 14361 6A 2NSE 25 6> 13595A 3NSE 15083 6> 27335A 4NSE 17388 6> 3095A 5NSE 100 6< 5374A 6NSE 22 6> 116815A 7
1.xls : https://app.box.com/s/38aoip5xi7018y9syt0xe4g04u95l6xk
macro.xlsm : https://app.box.com/s/599q2it3uck3hfwm5kscmmgtn0be66wt
Alert.csv : https://app.box.com/s/4ejptbaggn67nc91yz9jhgcefm2qae0r




Reply With Quote
Bookmarks