I hope someone can help me.. I am a beginner and sit here since 5 hours to do this work :(
I need to compare two cells. When the Cell 1 have the same value than Cell 2 i have to copy the value into the next 3 cells next to cell 2. When they aren't the same value, then the loop should go one cell down. And this down to the last filled cell.
Workbook 1 have the range G1:G100 this should be compared with the Workbook 2 and range B1:100
If the the content is the same in both, then i have to copy the 3 next cells next to the WB2 range where the cells are similar C1:E100
And thats the code i have
Public Sub zusammenführen()
Dim cell As Range
Dim wb1 As Workbook
Set wb1 = ThisWorkbook
Dim wb2 As Workbook
Set wb2 = Application.Workbooks.Open("T:\folder\LWTP.xlsx")
For Each cell In wb1.Sheets(1).Range("G1:G100")
If ActiveCell.Value = wb2.Sheets("LWTP").Range("B1:B100").Value Then
MsgBox "Test"
End If
Next cell
End Sub
I hope you understand my english Thanks for help!
ActiveCell.Value
should becell.Value
so it uses the variable from your loopFor Each cell
. – PᴇʜIsError(cell.Value)
first. – braX