Aamir khan
New Member
- Joined
- Feb 11, 2018
- Messages
- 9
how can we highlight last edited cell e.g if i use A1 it will highlight after use and then i use B5 then highlighting remove from A1 and B5 will highlight
how can i do with conditional formating please give me solution
Option Explicit
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, ray
Private [COLOR="Navy"]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR="Navy"]As[/COLOR] Range)
[COLOR="Navy"]Dim[/COLOR] Dn [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]If[/COLOR] Not Intersect(Target, Range("A:N")) [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] Not Rng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
c = 0
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
c = c + 1
Dn.Interior.ColorIndex = ray(c, 1)
Dn.Borders.LineStyle = xlNone
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] If
c = 0
[COLOR="Navy"]Set[/COLOR] Rng = Target
ReDim ray(1 To Rng.Count, 1 To 2)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
c = c + 1
ray(c, 1) = Dn.Interior.ColorIndex
[COLOR="Navy"]Next[/COLOR] Dn
Target.Interior.ColorIndex = 6
Target.Borders.Weight = 2
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Option Explicit
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, temp [COLOR=navy]As[/COLOR] Range
Private [COLOR=navy]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR=navy]As[/COLOR] Range)
[COLOR=navy]If[/COLOR] Rng [COLOR=navy]Is[/COLOR] Nothing [COLOR=navy]Then[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Target
[COLOR=navy]Else[/COLOR]
Rng.Interior.Color = vbYellow
[COLOR=navy]If[/COLOR] Not temp [COLOR=navy]Is[/COLOR] Nothing [COLOR=navy]Then[/COLOR] temp.Interior.Color = xlNone
[COLOR=navy]Set[/COLOR] temp = Rng
[COLOR=navy]Set[/COLOR] Rng = Target
[COLOR=navy]End[/COLOR] If
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]