Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Is it possible to loop through text?

Is it possible to loop through text, as it would for number? For example:

Dim Text As Integer ' where Text = "Before", "Now", or "After"
For Text
' code goes here
' i.e. Me.Controls("txt" & Text).Visible = True
Next Text
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Is it possible to loop through text?

Dim sText As String
Dim ary As Variant
Dim i As Long

sText = "Before,Now,After"
ary = Split(sText, ",")
For i = LBound(ary) To UBound(ary)

'Me.Controls("txt" & ary(i)).Visible = True


--
---
HTH

Bob


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



"Sam Kuo" wrote in message
...
Is it possible to loop through text, as it would for number? For example:

Dim Text As Integer ' where Text = "Before", "Now", or "After"
For Text
' code goes here
' i.e. Me.Controls("txt" & Text).Visible = True
Next Text



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Is it possible to loop through text?

It can be done this way also...

Dim V As Variant
For Each V In Split("Before,Now,After", ",")
Me.Controls("txt" & V).Visible = True
Next

Rick


"Bob Phillips" wrote in message
...
Dim sText As String
Dim ary As Variant
Dim i As Long

sText = "Before,Now,After"
ary = Split(sText, ",")
For i = LBound(ary) To UBound(ary)

'Me.Controls("txt" & ary(i)).Visible = True


--
---
HTH

Bob


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



"Sam Kuo" wrote in message
...
Is it possible to loop through text, as it would for number? For example:

Dim Text As Integer ' where Text = "Before", "Now", or "After"
For Text
' code goes here
' i.e. Me.Controls("txt" & Text).Visible = True
Next Text




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Is it possible to loop through text?

Hi Bob and Rick
Thanks alot!

"Rick Rothstein (MVP - VB)" wrote:

It can be done this way also...

Dim V As Variant
For Each V In Split("Before,Now,After", ",")
Me.Controls("txt" & V).Visible = True
Next

Rick


"Bob Phillips" wrote in message
...
Dim sText As String
Dim ary As Variant
Dim i As Long

sText = "Before,Now,After"
ary = Split(sText, ",")
For i = LBound(ary) To UBound(ary)

'Me.Controls("txt" & ary(i)).Visible = True


--
---
HTH

Bob


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



"Sam Kuo" wrote in message
...
Is it possible to loop through text, as it would for number? For example:

Dim Text As Integer ' where Text = "Before", "Now", or "After"
For Text
' code goes here
' i.e. Me.Controls("txt" & Text).Visible = True
Next Text





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
Worksheet loop not replacing new text SCrowley Excel Programming 0 April 10th 08 06:05 PM
VBA Loop Formatting Text Question Richard Excel Programming 3 June 13th 06 05:08 PM
Msg Box on each Loop to Replace text Ricky Pang Excel Programming 10 May 10th 06 11:47 PM
Forms - Loop thru text boxes Michael Beckinsale Excel Programming 9 April 10th 06 06:54 PM
End a loop if text is not found Ernesto[_3_] Excel Programming 2 August 19th 05 10:33 PM


All times are GMT +1. The time now is 11:48 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"