Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SetFocus using variable name

I would like to setfocus on a control in a user form
using a variable name.

ex:
sField = worksheets(5).cells(nval,1)
sField.SetFocus

The value in worksheets(5).cells(nval,1) would be the
name of a control on a user form

Can this be done?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default SetFocus using variable name

Taras,

Try

sField = Worksheets(2).Cells(1, 1)
Me.Controls(sField).SetFocus

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Taras" wrote in message
...
I would like to setfocus on a control in a user form
using a variable name.

ex:
sField = worksheets(5).cells(nval,1)
sField.SetFocus

The value in worksheets(5).cells(nval,1) would be the
name of a control on a user form

Can this be done?

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SetFocus using variable name

Bob,
That did it. Thanks.
-----Original Message-----
Taras,

Try

sField = Worksheets(2).Cells(1, 1)
Me.Controls(sField).SetFocus

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Taras" wrote in message
...
I would like to setfocus on a control in a user form
using a variable name.

ex:
sField = worksheets(5).cells(nval,1)
sField.SetFocus

The value in worksheets(5).cells(nval,1) would be the
name of a control on a user form

Can this be done?

TIA



.

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
SetFocus on a different sheet in VBA AaronC Excel Discussion (Misc queries) 1 June 9th 05 11:18 PM
SetFocus Problems Zane Greer Excel Programming 1 September 20th 03 02:26 PM
SetFocus problem RFraley Excel Programming 2 September 7th 03 01:18 PM
SetFocus method in VBA Robin S. Excel Programming 2 July 16th 03 10:20 PM
TextBox.SetFocus steve Excel Programming 4 July 16th 03 07:40 PM


All times are GMT +1. The time now is 11:16 AM.

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"