LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Make a Better Userform


I have a userform that allows me to add the last and first names of my
clients. Below is the code for the cmdbutton on that userform.


Code:
--------------------

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim newSheetName As String
Set ws = Worksheets("CGS")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.LstNm.Value) = "" Then
Me.LstNm.SetFocus
MsgBox "Please enter last name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.LstNm.Value
ws.Cells(iRow, 5).Value = Me.FrstNm.Value
newSheetName = ws.Cells(iRow, 1) & "," & ws.Cells(iRow, 5)

'clear the data
Me.LstNm.Value = ""
Me.FrstNm.Value = ""
Me.LstNm.SetFocus

For Each ws In Worksheets
If ws.Name = newSheetName Or _
newSheetName = "" Or _
IsNumeric(newSheetName) Then
MsgBox "Sheet already exists or name is invalid", vbInformation
Exit Sub
End If

Next
Sheets("SS").Visible = xlSheetVisible
Sheets("SS").Copy befo=Sheets(1)
Sheets("SS").Visible = xlSheetVeryHidden
Sheets(1).Name = newSheetName
Sheets(newSheetName).Move After:=Sheets(Sheets.Count)

'close userform
Unload Me
End Sub

--------------------


I would like to add the ability to have that client information added
to another worksheet within my workbook (worksheet 'at'). I would like
for it to start the insert at cell 'b10'.

I would also like for the userform to return me back to worksheet 'CGS'
before it closes.

Please keep explanations very simple. I am new at this and I ask tons
of questions simply because I am taken by the ablity to do this type of
work.


--
oberon.black
------------------------------------------------------------------------
oberon.black's Profile: http://www.excelforum.com/member.php...o&userid=26732
View this thread: http://www.excelforum.com/showthread...hreadid=466691

 
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
How do you make a userform open automatically when you open excel? Evan Excel Worksheet Functions 1 March 11th 10 02:24 AM
Sow do i make a userform know if a value is true in a frame, then CSUS_CE_Student[_2_] Excel Discussion (Misc queries) 1 May 13th 07 11:30 PM
how do i make a button from a userform exit onto the document in . Pieface New Users to Excel 1 April 17th 07 07:35 PM
How to make userform work publically with hidden sheets? Zigball Excel Discussion (Misc queries) 7 October 25th 06 03:30 PM
How to make userform work publically with hidden sheets? Zigball Excel Worksheet Functions 7 October 25th 06 03:30 PM


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