Dear all
Please kindly adjust my code to a better one. Esp the red part. I have no idea how to deal with selected cells or range
The code does something like below table
<tbody>
</tbody>
Please kindly adjust my code to a better one. Esp the red part. I have no idea how to deal with selected cells or range
Rich (BB code):
Sub Test()
Dim Row As Integer
Dim Col As Integer
Dim Cels As Range
Dim Rng As Range
Row = ActiveCell.Row
Col = ActiveCell.Column + 2
Set Rng = Range(Cells(ActiveCell.Row, ActiveCell.Column), Cells(ActiveCell.End(xlDown).Row, (ActiveCell.Column + 1))) ''In fact I want a selected range
For Each Cels In Rng
Cells(Row, Col) = Cels
Row = Row + 1
Next Cels
End Sub
A | B | C | |
1 | 1 | A | 1 |
2 | 2 | B | A |
3 | 3 | C | 2 |
4 | 4 | D | B |
5 | 5 | E | 3 |
6 | C | ||
7 | 4 | ||
8 | D | ||
9 | 5 | ||
10 | E |
<tbody>
</tbody>
Last edited: