Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dynamic userform field names

Hi

I am trying to split some text from one textbox in to multiple text
boxes. Basically in the first text box (seq_a) the user will paste a
seqeunce and this will then be split into individual bases with one
per text box (the text boxes are named a1-a20). The problem is how to
refer to the individual text boxes, at the moment the only way i can
see to do this is individually refer to the boxes:

a1 = Mid(seq_a, 1, 1)
a2 = Mid(seq_a, 2, 1)
a3 = Mid(seq_a, 3, 1)
......

But there must be a way to do so dynamically something like:

For i = 1 To Len(seq_a)
"a" & i = Mid(seq_a, i, 1)
next i

but "a" & i does not work and I am not sure if one can actually do
this step dynamically

Richard




Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Dynamic userform field names

Assuming we are talking forms textboxes

For i = 1 To Len(seq_a)
Me.Controls("a" & i).Text = Mid(seq_a, i, 1)
next i


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"rsphorler" wrote in message
...
Hi

I am trying to split some text from one textbox in to multiple text
boxes. Basically in the first text box (seq_a) the user will paste a
seqeunce and this will then be split into individual bases with one
per text box (the text boxes are named a1-a20). The problem is how to
refer to the individual text boxes, at the moment the only way i can
see to do this is individually refer to the boxes:

a1 = Mid(seq_a, 1, 1)
a2 = Mid(seq_a, 2, 1)
a3 = Mid(seq_a, 3, 1)
.....

But there must be a way to do so dynamically something like:

For i = 1 To Len(seq_a)
"a" & i = Mid(seq_a, i, 1)
next i

but "a" & i does not work and I am not sure if one can actually do
this step dynamically

Richard




Next i



  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Dynamic userform field names

Richard

I am not totally sure what you are trying to do, but, the following
code should head you in the right direction. If you have 4 textboxes
on a worksheet, and you put 4 characters as the text in the first one,
then run this code, one character of the initial value in textbox1
will go into each of the 4 textboxes.

Sub test()

i = 1
seq_a = ActiveSheet.OLEObjects(1).Object.Value
For Each oleob In ActiveSheet.OLEObjects
If TypeOf oleob.Object Is msforms.TextBox Then
oleob.Object.Value = Mid(seq_a, i, 1)
i = i + 1
End If
Next
End Sub

Good luck.


Ken
Norfolk, Va




On Jan 9, 5:05*pm, rsphorler wrote:
Hi

I am trying to split some text from one textbox in to multiple text
boxes. Basically in the first text box (seq_a) the user will paste a
seqeunce and this will then be split into individual bases with one
per text box (the text boxes are named a1-a20). The problem is how to
refer to the individual text boxes, at the moment the only way i can
see to do this is individually refer to the boxes:

a1 = Mid(seq_a, 1, 1)
a2 = Mid(seq_a, 2, 1)
a3 = Mid(seq_a, 3, 1)
.....

But there must be a way to do so dynamically something like:

For i = 1 To Len(seq_a)
"a" & i = Mid(seq_a, i, 1)
next i

but "a" & i does not work and I am not sure if one can actually do
this step dynamically

Richard

Next i


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dynamic userform field names

On Jan 9, 4:50*pm, "Bob Phillips" wrote:
Assuming we are talking forms textboxes

For i = 1 To Len(seq_a)
* * Me.Controls("a" & i).Text = Mid(seq_a, i, 1)
next i

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"rsphorler" wrote in message

...



Hi


I am trying to split some text from one textbox in to multiple text
boxes. Basically in the first text box (seq_a) the user will paste a
seqeunce and this will then be split into individual bases with one
per text box (the text boxes are named a1-a20). The problem is how to
refer to the individual text boxes, at the moment the only way i can
see to do this is individually refer to the boxes:


a1 = Mid(seq_a, 1, 1)
a2 = Mid(seq_a, 2, 1)
a3 = Mid(seq_a, 3, 1)
.....


But there must be a way to do so dynamically something like:


For i = 1 To Len(seq_a)
"a" & i = Mid(seq_a, i, 1)
next i


but "a" & i does not work and I am not sure if one can actually do
this step dynamically


Richard


Next i- Hide quoted text -


- Show quoted text -


Thanks to both of you the simple code above worked great

Richard
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
Dynamic autofilter field merry_fay Excel Discussion (Misc queries) 2 March 17th 10 02:11 PM
field names pjbur2005 via OfficeKB.com Excel Programming 0 January 12th 07 12:54 AM
Dynamic Field Selection - Calculation Matt Cromer Excel Discussion (Misc queries) 1 August 21st 06 11:13 PM
Pivot Table - Dynamic Field carlyman Excel Discussion (Misc queries) 3 August 26th 05 12:05 AM
redim of a double dynamic field Jurry[_8_] Excel Programming 0 May 4th 04 10:41 AM


All times are GMT +1. The time now is 06:27 PM.

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

About Us

"It's about Microsoft Excel"