PDA

View Full Version : Solved: "Active Row" use in Macro



cmpgeek
09-19-2006, 08:20 AM
How do I change the following coding so that it will highlight the the entire row where the selected cell is located?


Selection.Insert Shift:=xlToRight
Rows("42:42").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With


I know that Rows("42:42").Select is the problem; I am just not sure what needs to be there so that it highlights the whole row and not just the cell that is selected (if that is possible)...

Thanks,

lucas
09-19-2006, 08:35 AM
See if this helps:

Rows("42:42").Rows.EntireRow.Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

Norie
09-19-2006, 08:46 AM
Try this.

With Rows("42:42").Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

lucas
09-19-2006, 08:48 AM
Yep, thats better Norie....no selection necessary. Thanks

cmpgeek
09-19-2006, 09:10 AM
the problem is that I don't want it to highlight row 42 every time. That was the row I happened to pick when I initially recorded the macro... I am hoping that if I select a cell and initiate the macro that the macro will move the selected cell to the right 1 block and will then highlight the entire row...

So if I select B15, it will insert a cell and shift my selected cell over to the right and then highlight all of row 15... (i hope I am explaining this so that it makes sense)...

is there coding that will affect an entire row even if only one cell within the row is selected?

thanks yall!

Norie
09-19-2006, 09:20 AM
the problem is that I don't want it to highlight row 42 every time.
Kind of thought that might be the case.:)

If you just wanted to do this for the row the active cell is in then try this.

With ActiveCell.EntireRow.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

cmpgeek
09-19-2006, 09:23 AM
That is just what I was hoping for!!!

Thank you so much!

mdmackillop
09-19-2006, 11:38 AM
As xlSolid appears to be the default

ActiveCell.EntireRow.Interior.ColorIndex = 6

Cyberdude
09-23-2006, 01:44 PM
How about this:
Rows("42").Interior.ColorIndex = 6 I don't understand the benefit of "42:42" when "42" does the job.