Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ryk Ryk is offline
external usenet poster
 
Posts: 36
Default Macro to turn on/off rowliner?

I found this bit and just love it, but really would like it to be
disabled on startup, and have off/on button I can clickit off to
copy/paste etc (this stops copy/paste when used). Also need off button
to return row to old format.
Any ideas how I can do all this, or if it can be done at all?

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Const cnNUMCOLS As Long = 256
Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long
Dim i As Long
If Not rOld Is Nothing Then 'Restore color indices
With rOld.Cells
If .Row = ActiveCell.Row Then Exit Sub 'same row, don't
restore
For i = 1 To cnNUMCOLS
.Item(i).Interior.ColorIndex = nColorIndices(i)
Next i
End With
End If
Set rOld = Cells(ActiveCell.Row, 1).Resize(1, cnNUMCOLS)
With rOld
For i = 1 To cnNUMCOLS
nColorIndices(i) = .Item(i).Interior.ColorIndex
Next i
.Interior.ColorIndex = cnHIGHLIGHTCOLOR
End With
End Sub


Thanks

Dave (AKA Ryk)

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Macro to turn on/off rowliner?

Hi Ryk,

May be you could have in Workbook_Open() a test or Msgbox to ask user
if Rowliner is needed or not ...

HTH
Cheers
Carim

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ryk Ryk is offline
external usenet poster
 
Posts: 36
Default Macro to turn on/off rowliner?


Carim wrote:
Hi Ryk,

May be you could have in Workbook_Open() a test or Msgbox to ask user
if Rowliner is needed or not ...

HTH
Cheers
Carim


If I understood how too do that hehe, can I get a bit of info? Not the
best at excel.

Dave

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Macro to turn on/off rowliner?

Ryk,

Following code should help ...

Private Sub Workbook_Open()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to use Row Highlighter ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Choice"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
MyString = "Yes"
Range("A1").Value = 1 ' Adjust to your needs
Else
MyString = "No"
Range("A1").Value = 0
End If
End Sub

This code is to be copied in the module ThisWorkbook (after all your
sheets modules)

In addition, you have to add a test into your sheet module at the very
begining :

If Range("A1").Value = 0 Then
Exit Sub
Else
....
End If ' do not forget to add end if just before End Sub

HTH
Cheers
Carim

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Macro to turn on/off rowliner?

Ryk,

Just tested code ... in order for the second bit of code to work
properly, you should rather replace previous suggestion by following :

If Range("A1").Value = 0 Then
Cells(1, 1).Resize(1, cnNUMCOLS).Interior.ColorIndex = xlNone
Exit Sub
Else
.....
End If
End Sub


HTH
Cheers
Carim



  #6   Report Post  
Posted to microsoft.public.excel.misc
Ryk Ryk is offline
external usenet poster
 
Posts: 36
Default Macro to turn on/off rowliner?


Not sure why Carim but it gives me an error and highlights the A1 in
the second bit of code you added, do I need name it sub something? The
rows I'd be highlighting are 6-1006 and B6 would always have info in
it, my A1 is blank, I tried change it to B6 but no effect.

Thanks

Dave

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default Macro to turn on/off rowliner?

Hi Dave,

If you have picked the cell B6 to be your test cell ,

( i.e. the cell in which you or the event macro inputs 0 or 1 which in
turn allows or disallows your row highlighter macro ) , then your
should have, in your Selection_Change module :

Cells (6,2) instead of Cells (1,1) in your code ...

HTH
Cheers
Carim

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I turn the Macro Stop Recording Toolbar on and off? BamaBarks Excel Discussion (Misc queries) 5 November 27th 09 03:22 PM
how do I email amacro? leo Excel Worksheet Functions 24 August 9th 06 02:47 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
link to combobox legepe Excel Discussion (Misc queries) 4 July 26th 06 04:45 PM
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM


All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"