Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default UserForm code help needed.


Dude,

That's pretty much what I needed. Unfortunately, there are a couple o
cases where I need to limit what's being input by using comboboxes. Ho
would I fit those into it?

dude Wrote:
I assume that you are trying to add data from your form in
to database format? If so, you could just simply read the
user input from the form into a simple array and then add
data to your table this way.
something like this may work:

Private Sub CommandButton1_Click()

ReDim mydata(4)

For na = 0 To 3
mydata(na) = Controls(na).Text
Controls(na).Text = ""
Next

Dim NewRecordRng As Object
Set NewRecordRng = Worksheets("sheet1").Cells(2,
1).CurrentRegion
'Put new values into worksheet just below those rows.
newrow = NewRecordRng.Rows.Count + 1

With NewRecordRng
For na = 0 To 3
.Cells(newrow, na + 1).Value = mydata(na)
Next
End With
TextBox2.SetFocus
End Sub

I have only shown 4 textboxes but you can modify to meet
your needs. To see if this works for you. create a form &
add 4 textboxes then add a button(in that order) Double
click the button and past above code. You need a sheet
named sheet1. Run the form & enter data. It should add
data to sheet1 & clear textboxes for next entry. further
entry should be placed on next line.

Hope helpful

.



--
madblok
-----------------------------------------------------------------------
madbloke's Profile: http://www.excelforum.com/member.php...fo&userid=1442
View this thread: http://www.excelforum.com/showthread.php?threadid=26092

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default UserForm code help needed.

a combobox is a control - you should be able to read data
in to your array in same way.
If you create a test form as suggested. Add a combobox in
place of one of the textboxes (remember to add the button
on your form as last item (it's a control as well!)) Run
the form & add test data. It should place data from both
text & comboboxes into the worksheet.

hope helpful
-----Original Message-----

Dude,

That's pretty much what I needed. Unfortunately, there

are a couple of
cases where I need to limit what's being input by using

comboboxes. How
would I fit those into it?

dude Wrote:
I assume that you are trying to add data from your

form in
to database format? If so, you could just simply read

the
user input from the form into a simple array and then

add
data to your table this way.
something like this may work:

Private Sub CommandButton1_Click()

ReDim mydata(4)

For na = 0 To 3
mydata(na) = Controls(na).Text
Controls(na).Text = ""
Next

Dim NewRecordRng As Object
Set NewRecordRng = Worksheets("sheet1").Cells(2,
1).CurrentRegion
'Put new values into worksheet just below those rows.
newrow = NewRecordRng.Rows.Count + 1

With NewRecordRng
For na = 0 To 3
.Cells(newrow, na + 1).Value = mydata(na)
Next
End With
TextBox2.SetFocus
End Sub

I have only shown 4 textboxes but you can modify to

meet
your needs. To see if this works for you. create a

form &
add 4 textboxes then add a button(in that order) Double
click the button and past above code. You need a sheet
named sheet1. Run the form & enter data. It should add
data to sheet1 & clear textboxes for next entry.

further
entry should be placed on next line.

Hope helpful

.



--
madbloke
---------------------------------------------------------

---------------
madbloke's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=14422
View this thread:

http://www.excelforum.com/showthread...hreadid=260925

.

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
NEED A MACRO CODE TO USE IN A USERFORM Rachel Excel Discussion (Misc queries) 3 November 25th 08 10:08 AM
UserForm code help needed. madbloke[_6_] Excel Programming 4 September 17th 04 04:12 PM
Userform Formula Help Needed timh2ofall Excel Programming 2 December 12th 03 10:55 PM
VBA code for Userform Martin Los Excel Programming 4 December 5th 03 03:04 PM
A pointer or two needed using userform Jim[_32_] Excel Programming 1 October 20th 03 06:04 PM


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