# Colour a Chosen Row

#### charllie

##### Well-known Member
Hi Folks,

I have a code linked to menu in my menu bar that allows me to highlight a row in a worksheet and then click this menu/button and it copies the choosen row and pastes it to another worksheet.

Does anyone know a code that i could add to my present that when the information is copied it will colour the selected row yellow.

I have looked at a few posts on MrExcel but cant seem to adapt any to work for me.

Thanks

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
charlie,

Post your code mate, then we can see what we're working with.

But something along these lines should do what you need, as long as the entire row is still selected...

Selection.Interior.ColorIndex = 6

Bob

Hi Bob,

Thanks for your reply.

Heres my code:
Code:
``````Dim bSelected() As Boolean, iPtr As Integer, lCur As Long, lRow As Long
Dim R As Range
Dim vFrCols As Variant, vData() As Variant
Dim wsTo As Worksheet

If ActiveSheet.Name <> "Schedule 2" Then
MsgBox "Currently Active Sheet Is Not Warehouse Schedule"
Sheets("Schedule 2").Select
Exit Sub
End If

Set wsTo = Sheets("Priority List")
ReDim bSelected(0 To 0)

For Each R In Selection
lCur = R.Row
If UBound(bSelected) < lCur Then ReDim Preserve bSelected(0 To lCur)
bSelected(lCur) = True
Next R

vFrCols = Split(expression:="A,F,B,J,I", delimiter:=",")
ReDim vData(1 To UBound(vFrCols) + 1)
lRow = 4 'This tells it where to place the information copied starting at row 5
For lCur = 2 To UBound(bSelected)
If bSelected(lCur) = True Then
lRow = lRow + 1
'wsTo.Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
For iPtr = 0 To UBound(vFrCols)
vData(iPtr + 1) = Cells(lCur, vFrCols(iPtr)).Value
Next iPtr
wsTo.Range("B" & lRow, Cells(lRow, UBound(vData)).Address).Value = vData
End If
Next lCur``````

I am not quite sure where to place yours. Can you point the obvious out to me please

Thanks

Hi Bob,

Just to let you know, i managed to sort it out now. Thanks for your help.

Replies
10
Views
255
Replies
2
Views
299
Replies
7
Views
289
Replies
26
Views
657
Replies
9
Views
261

Threads
1,196,054
Messages
6,013,126
Members
441,749
Latest member
batel19

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back