Excel 2000 (9.0.2720) vb-6.
We have a column of Cells and the SpinButton. Let say for this example:
column 1 row 1 cell have value "A"
column 1 row 2 cell have value "B"
column 1 row 3 cell have value "C"
Cell with value "A" is is highlited (has focus)
Now we press "SpinButton" down. We exchange values "A" and "B"
so we have B - row 1
A - row 2
C - no change
We want A in row 2 be in focus, so we activate Cells(1,2)in last statement of spin down subroutine.
Well - the cell is activated for a split of second and then SpinButton get a focus - taking focus off our cell !!!. Now
SpinButton is like two CommandButton but CommandButton have a property: TakeFocusOnClick - TRUE or FALSE but SpinButton don't.(In my opinion MS missed this - hmmmmm?)
So, SpinButton is geting focus after "spin down" event is already finished. Now Cell in row 2 (value A)is active but SpinButton has a focus. If we press "down" again it works good bcse SpinButton (having focus now) is not trying to get focus again. How to solve this ???.
A solution can be: - Option Explicit
-
-
Private Sub SpinButton1_GotFocus()
-
ActiveCell.Activate
-
End Sub
-
-
Private Sub SpinButton1_SpinDown()
-
Dim R As Integer
-
R = ActiveCell.Row + 1
-
If R > 65535 Then R = R - 1 'last row in sheet
-
Cells(R, 1).Activate
-
End Sub
-
-
Private Sub SpinButton1_SpinUp()
-
Dim R As Integer
-
R = ActiveCell.Row - 1
-
If R < 1 Then R = R + 1 'Firs row in sheet
-
Cells(R, 1).Activate
-
End Sub
Si, kapish :))
7 5091
Well, Mihail
I'm loosing a focus from a cell that should have it - every second time when I press SpinButton. Would be solution - set Focus on SpinButton before pressing it, as I explained before when SpinButton has a focus it don't try get it back, so my cell properly maintain her focus for now, but next clic and SB takes focus again - Kapish ?
Sorry, I'm wrong - It is not a solution to set focus on SB, you have to press it first then program knows that it was pressed, besides there is no instruction to set focus or activate SB ??!!
A solution can be: - Option Explicit
-
-
Private Sub SpinButton1_GotFocus()
-
ActiveCell.Activate
-
End Sub
-
-
Private Sub SpinButton1_SpinDown()
-
Dim R As Integer
-
R = ActiveCell.Row + 1
-
If R > 65535 Then R = R - 1 'last row in sheet
-
Cells(R, 1).Activate
-
End Sub
-
-
Private Sub SpinButton1_SpinUp()
-
Dim R As Integer
-
R = ActiveCell.Row - 1
-
If R < 1 Then R = R + 1 'Firs row in sheet
-
Cells(R, 1).Activate
-
End Sub
Si, kapish :))
NeoPa 32,556
Expert Mod 16PB
I handle this irritation by selecting the worksheet that the cell is on. I've sometimes found that not to work though. Try selecting the current selection instead :
Micha,
I totaly overlooked "Object_GotFocus()". Of course your solution is perfect. Si,Si Kapish now.!
Many thanks
Janusz
NeoPa - Thanks - I used Mihail solution.
Cheers
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ronny Sigo |
last post by:
Hello all,
I have to open a readonly Excel sheet from clicking on a button on an access
form. So far no problem:
Dim ObjXL As Excel.Application
Dim ObjXLBook As Excel.Workbook
Dim ObjXLSheet As...
|
by: Mike |
last post by:
Can I trigger a button press event without putting focus
on the button? I am making a form full of buttons that
can be used as a keyboard on a touchscreen. If I have a
textbox which has focus...
|
by: JoRo |
last post by:
I am working on a project where I want a very user-friendly interface.
I have a datagrid of categories that uses the EditCommandColumn to do
in-line editing of the category name. On the page is...
|
by: Philip Townsend |
last post by:
I have an aspx page that contains 2 user controls, each containing a
seperate textbox and button. I would like to specify that one of the
buttons recieve focus when the page loads. Also, I would...
|
by: devour |
last post by:
i am using glade+pygtk+python ,what i wanna do is get a float type number
from user, make some mathematical operations using python then output the result using glade.
i tried text entry but i...
|
by: pentahari |
last post by:
In VB6, I have created the form look like the message box. but one problem has occurred that the one button had already focused but the rectangle focus symbol appeared on the focused button. But the...
|
by: JFKJr |
last post by:
Hello everyone, the following is the code which opens an excel file and creates a toolbar button.
And, when I click the toolbar button as shown at line #28, the code should call the "Example"...
|
by: MitchR |
last post by:
Good Morning Folks;
I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |