Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data Validation not working (with a Worksheet_SelectionChange event) | Excel Programming | |||
Worksheet_SelectionChange not working | New Users to Excel | |||
Worksheet_SelectionChange | Excel Programming | |||
Worksheet_SelectionChange | Excel Programming | |||
Worksheet_SelectionChange stops working | Excel Programming |