Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i am trying to set up a user form where a first name and last name are
entered. The first name must be inserted under column a and last name under column b. Here is the code that i am using: Private Sub CommandButton1_Click() Dim ans As String Dim time As String Sheets("sheet1").Activate ans = Application.WorksheetFunction.CountA(Range("a:a")) + 1 Cells(ans, 1) = TextBox1.Text TextBox1.Text = "" time = Application.WorksheetFunction.Count(Range("b:b")) + 2 Cells(time, 1) = TextBox2.Text TextBox2.Text = "" End Sub This throws both under column a |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Darren,
Make a fix In line Cells(time, 1) = TextBox2.Text to Cells(time, 2) = TextBox2.Text Regards, Stefi €˛Darren€¯ ezt Ć*rta: i am trying to set up a user form where a first name and last name are entered. The first name must be inserted under column a and last name under column b. Here is the code that i am using: Private Sub CommandButton1_Click() Dim ans As String Dim time As String Sheets("sheet1").Activate ans = Application.WorksheetFunction.CountA(Range("a:a")) + 1 Cells(ans, 1) = TextBox1.Text TextBox1.Text = "" time = Application.WorksheetFunction.Count(Range("b:b")) + 2 Cells(time, 1) = TextBox2.Text TextBox2.Text = "" End Sub This throws both under column a |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Darren,
Try: '============= Private Sub CommandButton1_Click() Dim rng1 As Range Dim rng2 As Range With Sheets("Sheet1") '<<==== CHANGE Set rng1 = .Cells(Rows.Count, "A").End(xlUp)(2) Set rng2 = .Cells(Rows.Count, "B").End(xlUp)(2) End With rng1.Value = Me.TextBox1.Value rng2.Value = Me.TextBox2.Value End Sub '<<============= --- Regards, Norman "Darren" wrote in message ... i am trying to set up a user form where a first name and last name are entered. The first name must be inserted under column a and last name under column b. Here is the code that i am using: Private Sub CommandButton1_Click() Dim ans As String Dim time As String Sheets("sheet1").Activate ans = Application.WorksheetFunction.CountA(Range("a:a")) + 1 Cells(ans, 1) = TextBox1.Text TextBox1.Text = "" time = Application.WorksheetFunction.Count(Range("b:b")) + 2 Cells(time, 1) = TextBox2.Text TextBox2.Text = "" End Sub This throws both under column a |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pass variable from form to form to form | Excel Programming | |||
Strange issue freezing parent form when unloading a child form | Excel Programming | |||
how can I make a form number change everytime the form is opened | Excel Worksheet Functions | |||
form in excel to be attached to the emails address in the form upon sumission | Excel Programming | |||
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? | Excel Programming |