#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default TextBox

Hi

I'm trying to loop through a series of "TextBox", where I
take the content of the box if there is something there
into another box on another sheet.

Basicly this is what I'm trying to do:

j = 1

For i = 1 To 5
If Sheet2.TextBox[i] = "Not Applicable"
Else
Sheet3.TextBox[j].Value = Sheet2.TextBox[i]
End If
Next i

Can someone show me how I can do this with MS Excel VBA

Many many THANKS ! ! !

Cheers

René
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default TextBox

Something like

Dim i As Long

For i = 1 To ActiveSheet.OLEObjects.Count
If TypeName(ActiveSheet.OLEObjects(i).Object) = "TextBox" Then
If ActiveSheet.OLEObjects(i).Object.Value = "Not Applicable"
Then
ActiveSheet.OLEObjects(j).Value =
ActiveSheet.OLEObjects(i).Value

End If
End If
Next i


--

HTH

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

"René Gagnon" wrote in message
...
Hi

I'm trying to loop through a series of "TextBox", where I
take the content of the box if there is something there
into another box on another sheet.

Basicly this is what I'm trying to do:

j = 1

For i = 1 To 5
If Sheet2.TextBox[i] = "Not Applicable"
Else
Sheet3.TextBox[j].Value = Sheet2.TextBox[i]
End If
Next i

Can someone show me how I can do this with MS Excel VBA

Many many THANKS ! ! !

Cheers

René


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default TextBox

Another way if you kept the names of the textboxes nice:

Option Explicit
Sub testme()

Dim i As Long
Dim j As Long

j = 1
For i = 1 To 5
If LCase(Sheet2.OLEObjects("textbox" & i).Object.Value) = "not
applicable" Then
'do nothing
Else
Sheet3.OLEObjects("textbox" & j).Object.Value _
= Sheet2.OLEObjects("textbox" & i).Object.Value
End If
Next i

End Sub

But what's going on with your code. You never vary j. So sheet3's textbox1
gets updated up to 5 times.



René Gagnon wrote:[i]

Hi

I'm trying to loop through a series of "TextBox", where I
take the content of the box if there is something there
into another box on another sheet.

Basicly this is what I'm trying to do:

j = 1

For i = 1 To 5
If Sheet2.TextBox[i] = "Not Applicable"
Else
Sheet3.TextBox[j].Value = Sheet2.TextBox
End If
Next i

Can someone show me how I can do this with MS Excel VBA

Many many THANKS ! ! !

Cheers

René


--

Dave Peterson

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
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
Textbox to Textbox Troubled User Excel Discussion (Misc queries) 1 April 13th 07 03:44 AM
TextBox Rockee052[_7_] Excel Programming 3 January 21st 04 03:56 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 06:51 AM.

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"