Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Variable in a textbox reference?

is it possible to put a variable in a reference to a textbox? here is
my code:

For i = 1 To loads
Cells(8 + i, 3).Value = TextBoxPi.Value * 1.6
Next i

I have textboxes labeled TextBoxP1, TextBoxP2, etc. and I want to get
there values into worksheet cells only for a certain number (loads) of
textboxes. so I'm trying to increment it by i. I assume my code will
not work, but I'm wondering how this can be done. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Variable in a textbox reference?

These are textboxes in a userform?

if yes:

Option Explicit
Private Sub CommandButton1_Click()
Dim loads As Long
Dim i As Long
loads = 3
For i = 1 To loads
Worksheets("sheet1").Cells(8 + i, 3).Value _
= Me.Controls("TextBoxP" & i).Value * 1.6
Next i
End Sub

Jacob wrote:

is it possible to put a variable in a reference to a textbox? here is
my code:

For i = 1 To loads
Cells(8 + i, 3).Value = TextBoxPi.Value * 1.6
Next i

I have textboxes labeled TextBoxP1, TextBoxP2, etc. and I want to get
there values into worksheet cells only for a certain number (loads) of
textboxes. so I'm trying to increment it by i. I assume my code will
not work, but I'm wondering how this can be done. Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Variable in a textbox reference?

that's what i needed. Thank you!


Dave Peterson wrote:
These are textboxes in a userform?

if yes:

Option Explicit
Private Sub CommandButton1_Click()
Dim loads As Long
Dim i As Long
loads = 3
For i = 1 To loads
Worksheets("sheet1").Cells(8 + i, 3).Value _
= Me.Controls("TextBoxP" & i).Value * 1.6
Next i
End Sub

Jacob wrote:

is it possible to put a variable in a reference to a textbox? here is
my code:

For i = 1 To loads
Cells(8 + i, 3).Value = TextBoxPi.Value * 1.6
Next i

I have textboxes labeled TextBoxP1, TextBoxP2, etc. and I want to get
there values into worksheet cells only for a certain number (loads) of
textboxes. so I'm trying to increment it by i. I assume my code will
not work, but I'm wondering how this can be done. Thanks.


--

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
Can I reference a textbox in a formula in Excel SteveW[_3_] Excel Worksheet Functions 1 December 19th 08 03:40 PM
Validating a unique reference in a textbox Blondegirl[_10_] Excel Programming 4 May 18th 06 04:59 PM
How to copy text from a TextBox in a ActiveSheet to a variable Tom Ogilvy Excel Programming 2 August 19th 03 06:35 PM
How to copy text from a TextBox in a ActiveSheet to a variable pat Excel Programming 0 August 19th 03 05:06 PM
Variable TextBox Philipp Schramek Excel Programming 2 July 23rd 03 03:14 PM


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

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"