- Joined
- Jan 25, 2012
- Messages
- 1
- Reaction score
- 0
hy there,
I'm a newbie in vba. And I whant to make a macro which will run from the last row that was filled. Here's how I thought it will be :
Sub CopyDateClient()
Dim r As Range, lRow As Long, iCol As Integer
Application.ScreenUpdating = False
With Sheets("Master")
For Each r In .Range(.Cells(2, "e"), .Cells(2, "e").End(xlDown))
With Sheets("Frauda")
With .UsedRange.Rows.Count
lRow = Range("e6000").End(xlUp).Row
End With
Select Case r.Value
Case "client_activ", "fost_client", "client_wo"
For iCol = 2 To 8
.Cells(lRow, iCol).End(xlUp).Offset(1, 0).Value = r.Offset(0, iCol - 1).Value
Next
.Cells(lRow, "A").End(xlUp).Offset(1, 0).Value = r.Offset(0, iCol - 12).Value
Case "angajat", "prospect", "terta_parte", "agent"
Exit Sub
End Select
End With
Next
End With
Application.ScreenUpdating = True
End Sub
But it does't work i do't know way? This cod copy's just the first 3 rows and after that the same 3 rows instead of copy the 4 row.
What I did wrong?
I'm a newbie in vba. And I whant to make a macro which will run from the last row that was filled. Here's how I thought it will be :
Sub CopyDateClient()
Dim r As Range, lRow As Long, iCol As Integer
Application.ScreenUpdating = False
With Sheets("Master")
For Each r In .Range(.Cells(2, "e"), .Cells(2, "e").End(xlDown))
With Sheets("Frauda")
With .UsedRange.Rows.Count
lRow = Range("e6000").End(xlUp).Row
End With
Select Case r.Value
Case "client_activ", "fost_client", "client_wo"
For iCol = 2 To 8
.Cells(lRow, iCol).End(xlUp).Offset(1, 0).Value = r.Offset(0, iCol - 1).Value
Next
.Cells(lRow, "A").End(xlUp).Offset(1, 0).Value = r.Offset(0, iCol - 12).Value
Case "angajat", "prospect", "terta_parte", "agent"
Exit Sub
End Select
End With
Next
End With
Application.ScreenUpdating = True
End Sub
But it does't work i do't know way? This cod copy's just the first 3 rows and after that the same 3 rows instead of copy the 4 row.
What I did wrong?