Selecting highlighted data from one column and placing them in another column

R

ranjan.khan

Hi,

I have data in Column A. Some of the rows in Column A are highlighted
in yellow.

I would like to copy the highlighted data and paste them into Column
B.

For Example:

Column A

2342
1234
2121
5675
2321

Let's assume that 2342 and 2121 are highlighted.

So my resullt in Column B will be:

2342
2121

Keep in mind that I have n numbers of data in Column A.

S

Sandy Mann

Try this Macro:

Sub Colour()
Dim bCol As Long
Dim x As Long

bCol = 2

For x = 2 To 1000 'increase as required
If Cells(x, 1).Interior.ColorIndex > 0 Then
Cells(bCol, 2) = Cells(x, 1).Value
bCol = bCol + 1
End If

Next x

End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

Replace @mailinator.com with @tiscali.co.uk

R

ranjan.khan

Try this Macro:

Sub Colour()
Dim bCol As Long
Dim x As Long

bCol = 2

For x = 2 To 1000 'increase as required
If Cells(x, 1).Interior.ColorIndex > 0 Then
Cells(bCol, 2) = Cells(x, 1).Value
bCol = bCol + 1
End If

Next x

End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

Replace @mailinator.com with @tiscali.co.uk

Thank you. It works perfectly.

S

Sandy Mann

You're welcome, thanks for the feedback.

--

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings