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
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