Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA forms in excel

I use forms for data input in excel. I have a for named test. I have 10
fields on the form named t1 thru t10. Currently when I open the form I get
data from a sheet and put it in the field names using:
test.t1.value=sheetname.range("H8"). using this method I have to create 10
lines of code to populate the ten fields. How can I use a for next loop to
change the field name in test.t1.value while stepping through the loop ie;
t1, t2, t3 ect.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA forms in excel

You didn't share how you loop through the cells. So I used A1 to A3 in my
tests.

You'll have to change the name of the textbox, too.

Option Explicit
Private Sub UserForm_Initialize()
Dim iCtr As Long

For iCtr = 1 To 3 '10 for you
Me.Controls("textbox" & iCtr).Value _
= ActiveSheet.Cells(iCtr, "A").Text
Next iCtr

End Sub

tcassio wrote:

I use forms for data input in excel. I have a for named test. I have 10
fields on the form named t1 thru t10. Currently when I open the form I get
data from a sheet and put it in the field names using:
test.t1.value=sheetname.range("H8"). using this method I have to create 10
lines of code to populate the ten fields. How can I use a for next loop to
change the field name in test.t1.value while stepping through the loop ie;
t1, t2, t3 ect.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default VBA forms in excel

By Field, do you mean Text Box, Label, List Box, ComboBox ? Not familiar
with what a field is.


"tcassio" wrote in message
...
I use forms for data input in excel. I have a for named test. I have 10
fields on the form named t1 thru t10. Currently when I open the form I
get
data from a sheet and put it in the field names using:
test.t1.value=sheetname.range("H8"). using this method I have to create
10
lines of code to populate the ten fields. How can I use a for next loop
to
change the field name in test.t1.value while stepping through the loop ie;
t1, t2, t3 ect.



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
Forms in Excel Mary jane Excel Discussion (Misc queries) 4 July 18th 09 05:05 PM
forms in Excel Allison Excel Discussion (Misc queries) 1 October 24th 06 11:21 PM
Excel forms - authorise / deny forms Ian Manning Excel Programming 1 May 8th 06 05:03 PM
RefEdits and normal forms / forms in a DLL David Welch Excel Programming 0 December 1st 04 03:49 PM
Calling Forms from Forms - Exit problems Stuart[_5_] Excel Programming 3 May 25th 04 06:50 AM


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