" if i need to do something on a certain sheet then...
sheets("sheet1").activate"
If I want to do something on that sheet, I'd do something like this
Dim myWS as Excel.worksheet
Set myWS = Worksheets("Sheet1")
myWS.Cells(1,1).value = "enter Value"
Blah blah blah. YOu generally don't need to activate anything to make
changes to any sheet. Besides, doing all that activating and selecting is
slow.
"FSt1" wrote:
> hi
> i think you are trying to make this WAY more complicated that it is.
> active = focus.
> i can't understand what would be gained by looping through the sheets to see
> which one is active. if i need to do something on a certain sheet then...
> sheets("sheet1").activate
> now sheet 1 has focus. run code.
> back to my question. what are you trying to achieve? why are we trying to
> find the active sheet? technically the sheet your are looking at on the
> screen is the active sheet.
> confused here. please help.
>
> regards
> FSt1
>
> regards
> FSt1
>
>
>
>
> "Matt" wrote:
>
> > Hi and thanks for the reply. I'm less concerned about the keyboard
> > specifically, and more interested to see if there is a way to check if a
> > sheet (any sheet) has focus. One thing I thought of is to check the value of
> > ActiveSheet, however this doesn't always work because ActiveSheet has a value
> > even when the Options Dialog is open (or any other dialog for that matter).
> > It also has a value while editing within a cell. Do you know if there is a
> > way to accomplish the following:
> >
> > If ActiveSheet.HasFocus = True Then
> > [Do Something]
> > End If
> >
> > Thanks for the help!
> >
> > Matt
> >
> > "FSt1" wrote:
> >
> > > hi
> > > the keyboard is just another input device like the mouse. or the bar coded
> > > reader.
> > > how do you determine if the mouse has "focus"?? well...you don't know unitl
> > > a button(key) is pressed then the input device has "focus". if the keyboard
> > > has "focuss" then we may be talking about "keyboard shortcuts" which does
> > > cause code to run i.e. do something. I think that is why we don't seem to
> > > have "isKeyboardFocused" property or a "ismousefocused" property.
> > > having been confused by your post, could you explain further just what your
> > > are trying to accomplish?
> > >
> > > regards
> > > FSt1
> > >
> > > "Matt" wrote:
> > >
> > > > What I'm trying to accomplish is essentially the following:
> > > >
> > > > If ActiveSheet.IsKeyboardFocused = True Then
> > > > [Do Something]
> > > > End If
> > > >
> > > > Unfortunately, ActiveSheet/Worksheet does not have the IsKeyboardFocused
> > > > property (I pulled this property from a Button control as a functional
> > > > example).
> > > >
> > > > Is there a way to accomplish this If statement?
> > > >
> > > > Thanks,
> > > > Matt
|