Hello everyone,
This is my first post and I hope this site can be useful. It's hard to learn VBA on your own. I'm trying to make a macro that will take check to see if any names in a column on the first sheet exist in a column on another sheet. If the name is not in the second sheet, I want it to add the new name to the end of the second column. The columns will vary in lengths and I'm not sure how to program this. Below is what I have so far. It runs but doesn't do what I would like it to do. I think my biggest issue is the language. I'm used to matlab, but I'm rusty at programing in general. Thanks for the help every one!
![]()
Sub test() Workbooks("Book4").Activate Dim count As Long Dim count2 As Long Dim ws1 As Worksheet, ws2 As Worksheet Dim pos As Long Set ws1 = Workbooks("Book4").Worksheets("Current Week") Set ws2 = Workbooks("Book4").Worksheets("2013 Winall") count = ws1.UsedRange.Rows.count count2 = ws2.UsedRange.count ws1.Activate For i = 3 To count Cells(i, 4).Select pos = (count2 + (i - 2)) For j = 1 To count2 If StrComp(Selection, (ws2.Cells(j, 2))) = 1 And j <> count2 Then Selection.Copy ws2.Activate ws2.Cells(pos, 2).Select ActiveSheet.Paste Application.CutCopyMode = False Else End If Next j Next i End Sub
Bookmarks