LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
JK JK is offline
external usenet poster
 
Posts: 78
Default Filling a WS from a UserForm

I am using a UF to fill a WS with unit count and product. For example, 2
Widgets, 2 Gadgets, 2 Gidgets should fill as follows:
1 Widget
2 Widget
3 Gadget
4 Gadget
5 Gidget
6 Gidget
The following code works:
Private Sub CommandButton1_Click()

Dim myCell As Range

Set myCell = ActiveSheet.Range("A1")

Dim j As Long, k As Long, i As Long

ActiveSheet.Range("A1:B15").Value = ""

On Error Resume Next

j = 0

For k = 1 To 10 Step 2

For i = 1 To CLng(UserForm1.Controls("TB" & k).Text)

j = j + 1

myCell.Offset(j - 1, 0).Value = j

myCell.Offset(j - 1, 1).Value = _

UserForm1.Controls("TB" & k + 1).Text

Next i

Next k

myCell.Select

On Error GoTo 0

End Sub

However, my UF allows a unit count for up to 5 products. So when I enter
only the 3 products (Widget, Gadget, Gidget) the WS looks like this:

1 Widget

2 Widget
3 Gadget
4 Gadget
5 Gidget
6 Gidget
7
8
How can I correct the code to only count the 3 products entered?
Also (if I'm not pushing my luck), I would prefer to use a TB for the unit
count only, and a list box for the product. If a code can be written for
that, I would very much help with that also.
Thank you in advance.
Jim Kobzeff


 
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
filling userform textboxes Pierre via OfficeKB.com[_2_] Excel Programming 3 October 14th 05 08:16 PM
filling information from one cell and filling another. Dianne Excel Worksheet Functions 1 August 15th 05 08:14 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Using Esc Botton while filling in userform helmekki[_37_] Excel Programming 1 October 18th 04 01:19 PM
Filling Userform in Word with Excel cell value. AW Excel Programming 0 April 4th 04 10:15 PM


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