Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Input Form on Worksheet 1, Data on Worksheet 2

I created an input text boxes to collect name and social
security number on worksheet1. Then click on a command
button to transfer the name and SSN to worksheet2 and
then leave worksheet 1 blank for the next person to sign
up.

I want to use the single input form on worksheet 1 to
build a database on worksheet 2.

Can I do this?

Thanks
Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Input Form on Worksheet 1, Data on Worksheet 2

"Jim in Spokane" wrote in message ...
I created an input text boxes to collect name and social
security number on worksheet1. Then click on a command
button to transfer the name and SSN to worksheet2 and
then leave worksheet 1 blank for the next person to sign
up.

I want to use the single input form on worksheet 1 to
build a database on worksheet 2.

Can I do this?

Thanks
Jim


I've implemented this using a VBA UserForm. It contains 2 labels, 2
textboxes (txtName and txtSSN) and a command button. The code inside
UserForm1 is:

Private Sub CommandButton1_Click()
Dim dataSheet As Variant
Dim nextRow As Integer

'Create the Database sheet with column headings if it doesn't
exist

If Not worksheetExists("Database", ThisWorkbook) Then
Set dataSheet = Sheets.Add
dataSheet.Name = "Database"
Range("A1").Value = "Name"
Range("B1").Value = "SSN"
End If

Sheets("Database").Activate

'Determine the next free row and add the name and SSN entries

nextRow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row + 1
ActiveCell.Cells(nextRow, 1).Value = txtName.Text
ActiveCell.Cells(nextRow, 2).Value = txtSSN.Text

'Blank out the fields on the input form and return to Sheet1

txtName.Text = ""
txtSSN.Text = ""
Sheets("Sheet1").Activate

End Sub

Function worksheetExists(WSName As String, Optional WB As Workbook) As
Boolean
On Error Resume Next
worksheetExists = CBool(Len(IIf(WB Is Nothing, ActiveWorkbook,
WB).Worksheets(WSName).Name))
End Function

-----

The form is automatically displayed when the workbook is opened by
defining the following subroutine in the ThisWorkbook workbook within
VBA.

Private Sub Workbook_Open()
Sheets("Sheet1").Activate
Load UserForm1
UserForm1.Show
End Sub

-------

I hope this helps.
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
antomatic capiture data from other worksheet input Hank Excel Discussion (Misc queries) 5 August 26th 08 10:28 PM
Input data from one worksheet to another Yendorian Excel Discussion (Misc queries) 0 June 19th 07 09:06 AM
Using a Worksheet Form to add data to a separate worksheet databas Rawblyn Excel Worksheet Functions 3 March 7th 06 08:17 PM
Setting up a form to input into selected worksheet Bob Excel Discussion (Misc queries) 0 June 29th 05 10:53 PM
Budget input form/worksheet Mike Webb New Users to Excel 0 June 16th 05 02:40 PM


All times are GMT +1. The time now is 03:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"