ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Range as far as..... (https://www.excelbanter.com/excel-programming/288018-select-range-far.html)

universal[_24_]

Select Range as far as.....
 
Hello All,

Id like to be able to highlight a row (whichever I have the curso
currently on) but only as far as column AP.

As a start Ive got:

Sub VirtualRuler()

ActiveCell.EntireRow.Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
End Sub

But this highlights all the way across the page.

As a further point, it would be quite nice if the same button tha
turns it on then removes it again, but I suspect the best way to d
this would be to re-colour the whole page

--
Message posted from http://www.ExcelForum.com


John Wilson

Select Range as far as.....
 
universal??,

Try this:

Sub VirtualRuler()
Range(Range("A" & ActiveCell.Row), _
Range("AP" & ActiveCell.Row)).Select
With Selection.Interior
..ColorIndex = 36
..Pattern = xlSolid
End With
End Sub

John

"universal " wrote in message
...
Hello All,

Id like to be able to highlight a row (whichever I have the cursor
currently on) but only as far as column AP.

As a start Ive got:

Sub VirtualRuler()

ActiveCell.EntireRow.Select
With Selection.Interior
ColorIndex = 36
Pattern = xlSolid
End With
End Sub

But this highlights all the way across the page.

As a further point, it would be quite nice if the same button that
turns it on then removes it again, but I suspect the best way to do
this would be to re-colour the whole page.


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Select Range as far as.....
 
Sub VirtualRuler()
Cells.Interior.ColorIndex = xlNone
With Cells(ActiveCell.Row,1).Resize(1,42).Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
End Sub


--
Regards,
Tom Ogilvy


"universal " wrote in message
...
Hello All,

Id like to be able to highlight a row (whichever I have the cursor
currently on) but only as far as column AP.

As a start Ive got:

Sub VirtualRuler()

ActiveCell.EntireRow.Select
With Selection.Interior
ColorIndex = 36
Pattern = xlSolid
End With
End Sub

But this highlights all the way across the page.

As a further point, it would be quite nice if the same button that
turns it on then removes it again, but I suspect the best way to do
this would be to re-colour the whole page.


---
Message posted from http://www.ExcelForum.com/




universal[_25_]

Select Range as far as.....
 
Thanks everbody,

Worked a treat, and Im (slowly) learning!!

Eddie


---
Message posted from http://www.ExcelForum.com/


Beto[_3_]

Select Range as far as.....
 
universal < wrote:
Hello All,

Id like to be able to highlight a row (whichever I have the cursor
currently on) but only as far as column AP.

As a start Ive got:

Sub VirtualRuler()

ActiveCell.EntireRow.Select
With Selection.Interior
ColorIndex = 36
Pattern = xlSolid
End With
End Sub

But this highlights all the way across the page.

As a further point, it would be quite nice if the same button that
turns it on then removes it again, but I suspect the best way to do
this would be to re-colour the whole page.


If I understand correctly, you want something like this:
Sub Coloring()
Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 42)).Select
With Selection.Interior
If .ColorIndex < -4142 Then .ColorIndex = -4142 Else _
.ColorIndex = 36
Pattern = xlSolid
End With
End Sub

' You don't even need to select the cells.
Sub Coloring2()
With Range(Cells(ActiveCell.Row, 1), _
Cells(ActiveCell.Row, 42)).Interior
If .ColorIndex < -4142 Then .ColorIndex = -4142 Else _
.ColorIndex = 36
Pattern = xlSolid
End With
End Sub

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com