![]() |
Working with Worksheet_SelectionChange
I have following code in worksheet selection function.
Problem is that when i select Ctrl + A i.e. select all sheet and click on any cell then code executed for all the selected cell and format of sheet changes to the format of active cell. what i want is format should not change if all sheet is selected it should change only when single cell is selected and that cell should be from range "C7:AG151" What should i do with this, please help me. Private Sub Worksheet_SelectionChange(ByVal target As Range) If Not Application.Intersect(target, Range("C7:AG151")) Is Nothing Then If IsEmpty(ActiveCell.Value) = True Or ActiveCell.Value = "P(1st)" Call Present(target) end if end sub Sub Present(target) target.Activate With Selection.Interior Call ClearPass target.Font.ColorIndex = 3 target.Font.Bold = True target.HorizontalAlignment = xlCenter .ColorIndex = 0 Call SetPass ' .Pattern = xlSolid End With End Sub With Regards, Swapnil |
Working with Worksheet_SelectionChange
Maybe:
If Target.Cells.Count = Cells.Count Then MsgBox "Not whole sheet" End If NickHK "Snowy" wrote in message ups.com... I have following code in worksheet selection function. Problem is that when i select Ctrl + A i.e. select all sheet and click on any cell then code executed for all the selected cell and format of sheet changes to the format of active cell. what i want is format should not change if all sheet is selected it should change only when single cell is selected and that cell should be from range "C7:AG151" What should i do with this, please help me. Private Sub Worksheet_SelectionChange(ByVal target As Range) If Not Application.Intersect(target, Range("C7:AG151")) Is Nothing Then If IsEmpty(ActiveCell.Value) = True Or ActiveCell.Value = "P(1st)" Call Present(target) end if end sub Sub Present(target) target.Activate With Selection.Interior Call ClearPass target.Font.ColorIndex = 3 target.Font.Bold = True target.HorizontalAlignment = xlCenter .ColorIndex = 0 Call SetPass ' .Pattern = xlSolid End With End Sub With Regards, Swapnil |
Working with Worksheet_SelectionChange
Thank you Nick
It works NickHK wrote: Maybe: If Target.Cells.Count = Cells.Count Then MsgBox "Not whole sheet" End If NickHK "Snowy" wrote in message ups.com... I have following code in worksheet selection function. Problem is that when i select Ctrl + A i.e. select all sheet and click on any cell then code executed for all the selected cell and format of sheet changes to the format of active cell. what i want is format should not change if all sheet is selected it should change only when single cell is selected and that cell should be from range "C7:AG151" What should i do with this, please help me. Private Sub Worksheet_SelectionChange(ByVal target As Range) If Not Application.Intersect(target, Range("C7:AG151")) Is Nothing Then If IsEmpty(ActiveCell.Value) = True Or ActiveCell.Value = "P(1st)" Call Present(target) end if end sub Sub Present(target) target.Activate With Selection.Interior Call ClearPass target.Font.ColorIndex = 3 target.Font.Bold = True target.HorizontalAlignment = xlCenter .ColorIndex = 0 Call SetPass ' .Pattern = xlSolid End With End Sub With Regards, Swapnil |
All times are GMT +1. The time now is 08:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com