Macro used to get the results in the last post above
In support of this post
http://www.excelfox.com/forum/showth...ll=1#post13140
Previous macro
https://www.ozgrid.com/forum/index.p...38#post1234138
Code:' Old macro ( https://www.ozgrid.com/forum/index.php?thread/1227284-copy-and-paste-by-macro/&postID=1234138#post1234138 ) 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("AlertTestData.xlsx") ' Workbooks("Alert.csv") ' 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 If .Cells(i, 9).Value = "" Then ' do nothing Else 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 End If Else ' if column H of 1.xls is lower than column D of 1.xls If .Cells(i, 9).Value = "" Then ' do nothing Else 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 End If Next i End With End Sub




Reply With Quote
Bookmarks