Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello, could someone please help me with a Userform?
I need to create a Userform that asks the user the enter information in the following fields: Finance File No: Full Name: FY: Date of Request: Category: WBS Element No: Cost Centre Code: How Many New Lines: Please note that the Category field needs to be a a drop-down selection box. The data for the Category field is on a table on a worksheet (Named: Category). I have named the table: =Category!$A$2:$A$51 Once all the data fields have been filled by the user, then maybe the subroutine shown below could be used to create the new lines at the bottom of the worksheet and populate the data that was entered by the user. Example: the user has just filled in the following fields: Finance File No: FTAN00459 Full Name: KEVIN BROWN FY: 08-09 Date of Request: 27-FEB-09 Category: TRAINING WBS Element No: DSPT0019S Cost Centre Code: 100206 How Many New Lines: 6 The last empty row in the worksheet (Named: register) is cell A13. The userform and VBA code creates 6 new lines using the sub-routine below. So range A13: G18 will have the data filled in so it looks like this: (Cell: A13) FTAN00459, (Cell: B13) KEVIN BROWN, (Cell: C13) 08-09, (Cell: D13) 27-FEB-09, (Cell: E13) TRAINING, (Cell: F13) DSPT00195, (Cell: G13) 100206 (Cell: A14) FTAN00459, (Cell: B14) KEVIN BROWN, (Cell: C14) 08-09, (Cell: D14) 27-FEB-09, (Cell: E14) TRAINING, (Cell: F14) DSPT00195, (Cell: G14) 100206 (Cell: A15) FTAN00459, (Cell: B15) KEVIN BROWN, (Cell: C15) 08-09, (Cell: D15) 27-FEB-09, (Cell: E15) TRAINING, (Cell: F15) DSPT00195, (Cell: G15) 100206 (Cell: A16) FTAN00459, (Cell: B16) KEVIN BROWN, (Cell: C16) 08-09, (Cell: D16) 27-FEB-09, (Cell: E16) TRAINING, (Cell: F16) DSPT00195, (Cell: G16) 100206 (Cell: A17) FTAN00459, (Cell: B17) KEVIN BROWN, (Cell: C17) 08-09, (Cell: D17) 27-FEB-09, (Cell: E17) TRAINING, (Cell: F17) DSPT00195, (Cell: G17) 100206 (Cell: A18) FTAN00459, (Cell: B18) KEVIN BROWN, (Cell: C18) 08-09, (Cell: D18) 27-FEB-09, (Cell: E18) TRAINING, (Cell: F18) DSPT00195, (Cell: G18) 100206 Lastly, cell: H13 needs to be selected so the user can start entering more data. Any help on this would be very much appreciated. Kind regards, Chris. Sub New_Line() Range("A2").Select Application.ScreenUpdating = False 'I think that the last cell should be named here 'and not at the end of the sub. With Sheets("Register") 'Following line of code is like selecting the last cell 'in the column and holding the Ctrl key and press Up arrow 'It then names the cell. .Cells(.Rows.Count, "A").End(xlUp).Name = "LastCell" 'Following line finds last cell in column M and 'copies that cell formula to the row below. .Cells(.Rows.Count, "I").End(xlUp).Copy _ Destination:=.Cells(.Rows.Count, "I") _ .End(xlUp).Offset(1, 0) End With Range("LastCell").Select ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell.Rows("1:1").EntireRow.Select Selection.RowHeight = 25.5 ActiveCell.Range("A1:T1").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Font .Name = "Arial" .FontStyle = "Regular" .Size = 8 End With With Selection .VerticalAlignment = xlBottom .WrapText = True .Orientation = 0 .ShrinkToFit = False .MergeCells = False End With With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection .VerticalAlignment = xlBottom .WrapText = True .Orientation = 0 .ShrinkToFit = False .MergeCells = False End With Sheets("Register").Select Range("LastCell").Offset(1, 0).Select End Sub *** Sent via Developersdex http://www.developersdex.com *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fill userform textbox from userform listbox clik event | Excel Programming | |||
Is there an easy Copy/Paste of a Userform ? (Entire Userform Including tx & cbx's) | Excel Programming | |||
Userform to enter values and shown in same userform in list | Excel Programming | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
Activating userform and filling it with data form row where userform is activate | Excel Programming |