Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deselect cells with formulas in selection

Hi all,

i have one problem to solve and can't get it done.
(I am new to VBA)

I have a table with calls that the user can fill and some with formulas.
If the user makes a selection mith his mouse (e.g. from A1 to F20), he also
selects cells with formulas.
What i want to do, ist to deselct these cells by a script/vba program,
after the user made his selection, so that only the non-formula cells stay
selected.

How can i do this?

I think it has to be this way, but i don't know how to deselect a cell.

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
For Each c In Target
If c.HasFormula Then ???
Next
End Sub

I this the right way?
What is the missing comand?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deselect cells with formulas in selection

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range, d as Range
On Error goto ErrHandler
For Each c In Target
If Not c.HasFormula Then
if d is nothing then
set d = c
else
set d = union(d,c)
end if
Next
Application.EnableEvents = False
if not d is nothing then
d.Select
else
Range("A1").Select
end if
ErrHandler:
Application.EnableEvents = True
End Sub

If there are no cells that are blank - either constants or formulas, you
could use specialcells


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range, d as Range
On Error goto ErrHandler
Application.EnableEvents = False
d = target.specialcells(xlConstants)
if not d is nothing then
d.Select
else
Range("A1").Select
end if
ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy




"Thorsten Gleumes" wrote in message
...
Hi all,

i have one problem to solve and can't get it done.
(I am new to VBA)

I have a table with calls that the user can fill and some with formulas.
If the user makes a selection mith his mouse (e.g. from A1 to F20), he

also
selects cells with formulas.
What i want to do, ist to deselct these cells by a script/vba program,
after the user made his selection, so that only the non-formula cells stay
selected.

How can i do this?

I think it has to be this way, but i don't know how to deselect a cell.

'Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
For Each c In Target
If c.HasFormula Then ???
Next
End Sub

I this the right way?
What is the missing comand?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deselect cells with formulas in selection

"Tom Ogilvy" schrieb:


Many thanks, i will try you solution.

Thorsten
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
Deselect (Unselect) Cells gtabmx Excel Discussion (Misc queries) 15 January 6th 10 02:13 PM
deselect row/column from multiple selection Alan C Excel Discussion (Misc queries) 2 March 5th 09 05:53 PM
programmatically deselect a selection? Rich Excel Programming 4 February 24th 06 11:31 PM
Deselect Cells while using ctrl Sloth Excel Discussion (Misc queries) 5 July 14th 05 10:58 PM
Deselect of Cells Handler Robert[_3_] Excel Programming 4 February 18th 04 01:20 PM


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

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

About Us

"It's about Microsoft Excel"