|
-
Feb 27th, 2004, 06:42 AM
#1
Thread Starter
Hyperactive Member
Excel VBA - No cell selected
Well, it's one of those days,
There I was happily programming away in VB and someone comes along with an urgent Excel problem.
Without going into the detail of the whole requirement, what I need to do is if somebody clicks on a particular cell, I need to send the selected cell region elsewhere.
I have managed to select a different cell OK by using
Sheet1.Range("nm").Activate
So, for example, if the user clicks on A1 and that is one of the special cells, I pop up a message and select B1 instead.
What I would like to do is to have no cell selected if the user clicks on A1.
Is this possible?
Any help would be appreciated.
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
-
Feb 27th, 2004, 08:36 AM
#2
VB Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (ActiveCell.Address = "$A$1") Then
Cells(1, 2).Select
ElseIf (ActiveCell.Address = "$A$2") Then
Cells(2, 2).Select
End If
End Sub
I think Excel must have a cell selected at all times - I've never seen samples otherwise, so you're best bet would be to maybe select a cell the user isn't looking at to give that impression.
I.e. use the above code to select a cell on row 3000 for example & the user wouldn't see any cells selected on their screen then...
-
Feb 27th, 2004, 08:40 AM
#3
Addicted Member
Something like this ...........?
Code:
'--------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim NewAddress As String
Select Case Target.Address
Case "$A$1"
NewAddress = "B1"
Case "$A$2"
NewAddress = "B2"
Case Else
End
End Select
MsgBox ("Changing selection")
Range(NewAddress).Select
End Sub
'-------------------------------------------------
Regards
BrianB
-------------------------------
-
Feb 27th, 2004, 08:48 AM
#4
Thread Starter
Hyperactive Member
Thanks for the replies guys,
Sorry if I wasn't clear in my post. I had the moving to another cell bit working.
I just wanted to know if it was possible to have no cell selected after the user had clicked on one of the precious cells rather than moving the user to a cell of my choice.
Looks like the non visible cell option is the only way.
Thanks again.
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
-
Feb 28th, 2004, 11:59 AM
#5
Lively Member
Only way to have no cell selected in Excel that I have found is with the following:
Protected sheet (password is optional)
and the following vba code:
Worksheets(1).EnableSelection = xlNoSelection
You could set up your selection_change event that if in a certain cell, it would lock the sheet and set the xlNoSelection property.
Just give the user the ability to unlock sheet if he/she needs to continue entering data. Once unlocked, cells can be selected again.
-
Mar 1st, 2004, 03:59 AM
#6
Thread Starter
Hyperactive Member
Thanks TheFIDDLER,
I will give it a try.
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
-
Mar 3rd, 2004, 04:16 AM
#7
Junior Member
hOW i CAN TO OBTAIN VALUE FROM INTERSECTION RANGE ?
In Range("B1") I have "TEST1" in Range("A6") I have "TEST2"
in intersection range range("B6") I have "TEST3".
How I can to obtain this value "TEST3" ?
-
Mar 3rd, 2004, 04:57 AM
#8
Thread Starter
Hyperactive Member
Hi zigraj,
I don't know the answer to your question but I can give you some advice as to how you might get more people to see your question.
Because you have posted your question at the end of an existing thread, the only people likely to see it will be people subscribing to the thread (me and the three guys who were trying to help me) and anyone who just happens to look at the thread (not very likely).
Try starting a new thread and ask your question again.
Hope you get an answer
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|