Double For next loop

Trial and Error

New Member
Joined
Jan 26, 2012
Messages
3
Hi,

I am quite a newbie on this and try to step up to the next level...

The sub below tries to compare a list of new transactions on a worksheet with a second list on another worksheet. If a condition is met it should copy a range from the second list to the first.

I tried to write it all in once cause I couldn't think of a way to split it up and test it seperately. I am quite stuck since there are to much errors in here.

Does anyone has a suggestion where to look for a solution or have any helping comments on my sub?

Sub Test()


Application.ScreenUpdating = False

Dim w1 As Worksheet, w2 As Worksheet
Dim X As String
Set w1 = Worksheets("transacties")
Set w2 = Worksheets("historie")
Dim a1 As Long, b1 As Long
Dim RW1 As Long, RW2 As Long
RW1 = w1.Cells(Rows.Count, 1).End(xlUp).Row
RW2 = w2.Cells(Rows.Count, 1).End(xlUp).Row
X = w1.Cells(a1, 10).Text

For a1 = 2 To RW1
If w1.Cells(a1, 14) = "" _
Then For b1 = 2 To RW2
If InStr(1, X, w2.Cells(b1, 4)) Then Copy w2.Range("G &b1:O &b1") w1.Cells(a1,15).Paste
Next b1
Next a1


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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