S
sbitaxi
Hello!
The following code filters the values in a column for the value "y"
and then copies/combines the values of multiple cells in the same row
into other cells. There is probably a more efficient way of doing
this, but I haven't found it.
Here's the question - after successfully looping through all visible
rows, the code returns an error 91. As far as I can tell, it happens
when it reaches the last visible row. Is this why? How can I correct
it?
SrcEntRng.AutoFilter Field:=Range(PrefBAdd).Column,
Criteria1:="=y"
For Each MyCell In
Range(PrefBAdd).SpecialCells(xlCellTypeVisible)
' If MyCell.Value = "y" Then
MyCell.Offset(0, -13).Value =
Intersect(Rows(MyCell.Row), BAdd).Value _
& " " & Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 1)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 2)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 3)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 4)).Value
MyCell.Offset(0, -8).Value =
MyCell.Offset(0, 6).Value
MyCell.Offset(0, -7).Value =
MyCell.Offset(0, 7).Value
MyCell.Offset(0, -6).Value =
MyCell.Offset(0, 8).Value
MyCell.Offset(0, -5).Value =
MyCell.Offset(0, 9).Value
' End If
Next
SrcWS.AutoFilterMode = False
The following code filters the values in a column for the value "y"
and then copies/combines the values of multiple cells in the same row
into other cells. There is probably a more efficient way of doing
this, but I haven't found it.
Here's the question - after successfully looping through all visible
rows, the code returns an error 91. As far as I can tell, it happens
when it reaches the last visible row. Is this why? How can I correct
it?
SrcEntRng.AutoFilter Field:=Range(PrefBAdd).Column,
Criteria1:="=y"
For Each MyCell In
Range(PrefBAdd).SpecialCells(xlCellTypeVisible)
' If MyCell.Value = "y" Then
MyCell.Offset(0, -13).Value =
Intersect(Rows(MyCell.Row), BAdd).Value _
& " " & Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 1)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 2)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 3)).Value & " " _
& Intersect(Rows(MyCell.Row),
BAdd.Offset(0, 4)).Value
MyCell.Offset(0, -8).Value =
MyCell.Offset(0, 6).Value
MyCell.Offset(0, -7).Value =
MyCell.Offset(0, 7).Value
MyCell.Offset(0, -6).Value =
MyCell.Offset(0, 8).Value
MyCell.Offset(0, -5).Value =
MyCell.Offset(0, 9).Value
' End If
Next
SrcWS.AutoFilterMode = False