Why is the Else statement not working

Status
Not open for further replies.

wal_verin

New Member
Joined
Nov 21, 2018
Messages
15
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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Status
Not open for further replies.

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top