Hi all,
I have a code which succeeds to do all the others except for the Else statement, could someone please be of help to me?
Before i modified the code everything was working as they ought to but after some slight changes to make it more user friendly, the last Else statement stopped working.
Below lies my codes
Code[$]
'Change the link to where you saved your files
Set v = Worksheets("Sheet 2")
Set w = Worksheets("Sheet 1")
'Avoiding the buttons and rows with headings
LRow = w.Cells(w.Rows.Count, "A").End(xlUp).Row
'This is the for Statement
For Each Cell In v.Range("A1:A" & LRow)
For i = 8 To LRow
'If there is an Error do this
On Error Resume Next
'Set whenever you are dealing with Variant or Range
Set Kontonr = w.Range("A8:A200").Find(Cell.Value)
Set Target = v.Range("A:A").Find(w.Cells(i, 1), lookat:=xlWhole, LookIn:=xlValues)
If Not Kontonr Is Nothing Then
w.Range("C" & Kontonr.Row + 1).Value = v.Range("F" & Cell.Row & ":F" & Cell.Row).Value
ElseIf Target Is Nothing Then
w.Cells(i, 1).EntireRow.Interior.Color = vbYellow
Else
LRow = w.Cells(w.Rows.Count, "B").End(xlUp).Row + 1
w.Range("A" & LRow & ":C" & LRow).Value = v.Range("A" & Cell.Row, ":C" & Cell.Row).Value
End If
Next i
Next Cell
MsgBox "De gula markerade rader finns inte i den aktuella balansen, då ska de tas bort"
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Code[]
Thanks a million
I have a code which succeeds to do all the others except for the Else statement, could someone please be of help to me?
Before i modified the code everything was working as they ought to but after some slight changes to make it more user friendly, the last Else statement stopped working.
Below lies my codes
Code[$]
'Change the link to where you saved your files
Set v = Worksheets("Sheet 2")
Set w = Worksheets("Sheet 1")
'Avoiding the buttons and rows with headings
LRow = w.Cells(w.Rows.Count, "A").End(xlUp).Row
'This is the for Statement
For Each Cell In v.Range("A1:A" & LRow)
For i = 8 To LRow
'If there is an Error do this
On Error Resume Next
'Set whenever you are dealing with Variant or Range
Set Kontonr = w.Range("A8:A200").Find(Cell.Value)
Set Target = v.Range("A:A").Find(w.Cells(i, 1), lookat:=xlWhole, LookIn:=xlValues)
If Not Kontonr Is Nothing Then
w.Range("C" & Kontonr.Row + 1).Value = v.Range("F" & Cell.Row & ":F" & Cell.Row).Value
ElseIf Target Is Nothing Then
w.Cells(i, 1).EntireRow.Interior.Color = vbYellow
Else
LRow = w.Cells(w.Rows.Count, "B").End(xlUp).Row + 1
w.Range("A" & LRow & ":C" & LRow).Value = v.Range("A" & Cell.Row, ":C" & Cell.Row).Value
End If
Next i
Next Cell
MsgBox "De gula markerade rader finns inte i den aktuella balansen, då ska de tas bort"
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Code[]
Thanks a million