udigold1
12-23-2008, 08:15 AM
Hi, I have this problem, I want to copy from one range to another range only cells that meet some conditions. So far so good, trouble is that I use a "for" loop and I get gap in rows in the target range because I use the same counter for the two ranges.
here's the code I use :
Range(ret.Offset(1, 0), ret.End(xlDown)).Select
For i = 1 To Selection.Rows.Count
If ret.Offset(i, 0).Value > 1 And AccName.Offset(i, 0).Font.Bold = False Then
dhr.Offset(i, 0) = dat.Offset(i, 0)
ahr.Offset(i, 0) = act.Offset(i, 0)
nhr.Offset(i, 0) = niar.Offset(i, 0)
khr.Offset(i, 0) = AccName.Offset(i, 0)
End If
Next i
I don't want to have gaps in the target range, but I can't figure out what to do.
here's the code I use :
Range(ret.Offset(1, 0), ret.End(xlDown)).Select
For i = 1 To Selection.Rows.Count
If ret.Offset(i, 0).Value > 1 And AccName.Offset(i, 0).Font.Bold = False Then
dhr.Offset(i, 0) = dat.Offset(i, 0)
ahr.Offset(i, 0) = act.Offset(i, 0)
nhr.Offset(i, 0) = niar.Offset(i, 0)
khr.Offset(i, 0) = AccName.Offset(i, 0)
End If
Next i
I don't want to have gaps in the target range, but I can't figure out what to do.