S
sbitaxi
I'm sure my terminology is not correct, but the intention is there. I
have the following statement which combines cell values from several
into one.
For Each MyCell In
Range(PrefBAdd).SpecialCells(xlCellTypeVisible)
Do Until i = DestCols + 1
If MyCell.Row > 1 Then
Intersect(Range(HAdd), Rows(MyCell.Row)).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
i = i + 1
Exit Do
Loop
Next
Rather than using all those offsets, I'd prefer to use some form of
cross reference, it will make the code more flexible and easier to
apply to different data sets with different numbers of columns. Here
is my idea
Set FoundCell = Rng.Find(What:="MyHeaderRowValue"....
Set Hdr = Range(Cells(MyCell.Row, FoundCell.Column)
And then used in the above code like -
Hdr.Value = MyCell.Offset(0, 6).Value
How do I make the Hdr something that is dynamically assigned without
setting it again and again in a loop?
have the following statement which combines cell values from several
into one.
For Each MyCell In
Range(PrefBAdd).SpecialCells(xlCellTypeVisible)
Do Until i = DestCols + 1
If MyCell.Row > 1 Then
Intersect(Range(HAdd), Rows(MyCell.Row)).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
i = i + 1
Exit Do
Loop
Next
Rather than using all those offsets, I'd prefer to use some form of
cross reference, it will make the code more flexible and easier to
apply to different data sets with different numbers of columns. Here
is my idea
Set FoundCell = Rng.Find(What:="MyHeaderRowValue"....
Set Hdr = Range(Cells(MyCell.Row, FoundCell.Column)
And then used in the above code like -
Hdr.Value = MyCell.Offset(0, 6).Value
How do I make the Hdr something that is dynamically assigned without
setting it again and again in a loop?