PC Review


Reply
Thread Tools Rate Thread

conditionla format based on cursor location

 
 
=?Utf-8?B?dHQ2Ng==?=
Guest
Posts: n/a
 
      10th Sep 2007
I found this great code to highlight the current location of a cell. I am
not a code writer and have tried to adjust this code to highlight the cell
immediatly to the left of the current cursor location, but have not been
sucesfull.



Private Sub Worksheet_SelectionChange(ByVal Target As Range)


Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
ci = Target.Cells(1).Interior.ColorIndex
Target.Cells(1).Interior.ColorIndex = 36
Set c = Target.Cells(1)


End Sub


 
Reply With Quote
 
 
 
 
Trevor Shuttleworth
Guest
Posts: n/a
 
      10th Sep 2007
Try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static c As Range
Static ci As Integer
If Not c Is Nothing Then
c.Interior.ColorIndex = ci
End If
On Error Resume Next
ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
Set c = Target.Cells(1).Offset(0, -1)
On Error GoTo 0
End Sub

Regards

Trevor


"tt66" <(E-Mail Removed)> wrote in message
news:16158C63-95CE-4D75-BE9B-(E-Mail Removed)...
>I found this great code to highlight the current location of a cell. I am
> not a code writer and have tried to adjust this code to highlight the cell
> immediatly to the left of the current cursor location, but have not been
> sucesfull.
>
>
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
>
> Static c As Range
> Static ci As Integer
> If Not c Is Nothing Then
> c.Interior.ColorIndex = ci
> End If
> ci = Target.Cells(1).Interior.ColorIndex
> Target.Cells(1).Interior.ColorIndex = 36
> Set c = Target.Cells(1)
>
>
> End Sub
>
>



 
Reply With Quote
 
=?Utf-8?B?dHQ2Ng==?=
Guest
Posts: n/a
 
      10th Sep 2007
Excelent

Thanks

"Trevor Shuttleworth" wrote:

> Try:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Static c As Range
> Static ci As Integer
> If Not c Is Nothing Then
> c.Interior.ColorIndex = ci
> End If
> On Error Resume Next
> ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
> Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
> Set c = Target.Cells(1).Offset(0, -1)
> On Error GoTo 0
> End Sub
>
> Regards
>
> Trevor
>
>
> "tt66" <(E-Mail Removed)> wrote in message
> news:16158C63-95CE-4D75-BE9B-(E-Mail Removed)...
> >I found this great code to highlight the current location of a cell. I am
> > not a code writer and have tried to adjust this code to highlight the cell
> > immediatly to the left of the current cursor location, but have not been
> > sucesfull.
> >
> >
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> >
> >
> > Static c As Range
> > Static ci As Integer
> > If Not c Is Nothing Then
> > c.Interior.ColorIndex = ci
> > End If
> > ci = Target.Cells(1).Interior.ColorIndex
> > Target.Cells(1).Interior.ColorIndex = 36
> > Set c = Target.Cells(1)
> >
> >
> > End Sub
> >
> >

>
>
>

 
Reply With Quote
 
Trevor Shuttleworth
Guest
Posts: n/a
 
      10th Sep 2007
You're welcome. Thanks for the feedback.


"tt66" <(E-Mail Removed)> wrote in message
news:1FE0A188-1A50-4393-B4C6-(E-Mail Removed)...
> Excelent
>
> Thanks
>
> "Trevor Shuttleworth" wrote:
>
>> Try:
>>
>> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>> Static c As Range
>> Static ci As Integer
>> If Not c Is Nothing Then
>> c.Interior.ColorIndex = ci
>> End If
>> On Error Resume Next
>> ci = Target.Cells(1).Offset(0, -1).Interior.ColorIndex
>> Target.Cells(1).Offset(0, -1).Interior.ColorIndex = 36
>> Set c = Target.Cells(1).Offset(0, -1)
>> On Error GoTo 0
>> End Sub
>>
>> Regards
>>
>> Trevor
>>
>>
>> "tt66" <(E-Mail Removed)> wrote in message
>> news:16158C63-95CE-4D75-BE9B-(E-Mail Removed)...
>> >I found this great code to highlight the current location of a cell. I
>> >am
>> > not a code writer and have tried to adjust this code to highlight the
>> > cell
>> > immediatly to the left of the current cursor location, but have not
>> > been
>> > sucesfull.
>> >
>> >
>> >
>> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>> >
>> >
>> > Static c As Range
>> > Static ci As Integer
>> > If Not c Is Nothing Then
>> > c.Interior.ColorIndex = ci
>> > End If
>> > ci = Target.Cells(1).Interior.ColorIndex
>> > Target.Cells(1).Interior.ColorIndex = 36
>> > Set c = Target.Cells(1)
>> >
>> >
>> > End Sub
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Last Cursor Location app Microsoft Word Document Management 0 26th Jan 2011 10:57 AM
set location of Form2 based on Location of Form1? Rich P Microsoft C# .NET 9 1st Jul 2009 10:04 PM
Format the file location based on server location no the mapped dr BZeyger Microsoft Access 1 20th Feb 2009 04:38 AM
Insert Date - Format Text / Cursor Location srm Microsoft Outlook Form Programming 5 8th Sep 2008 11:41 AM
ADO Cursor location SKG Microsoft ASP .NET 1 11th Aug 2004 06:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:03 PM.