Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default trouble adding to list.

this code was working fine yesterday. at least i think i remember it working
as i finished a 20hr shift. any ways... it isn't now, and i have no idea
why. It is supposed to add a name and number from a userform to a list on
sheet2. Now it overwrites row 2 in either sheet, depending on which is active
when i run the userform.

any advice would be great.

Thanks in advance

Private Sub CommandButton2_Click()
With ActiveWorkbook.Worksheets("sheet2")
If TextBox1.Text < "" And Not .Range("A:A").Find(TextBox1.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's name already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("A:A").End(xlUp)(2).Select
Application.Selection.Value = TextBox1.Text
Cancel = False
If TextBox2.Text < "" And Not .Range("C:C").Find(TextBox2.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's Number already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("C:C").End(xlUp)(2).Select
Application.Selection.Value = TextBox2.Text
Cancel = False
End If
End If
End With

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default trouble adding to list.

Hi,


Change:

Range("A:A").End(xlUp)(2).Select
Application.Selection.Value = TextBox1.Text

to
..Cells(Rows.Count, "A").End(xlUp)(2) = TextBox1.Text

and repeat ...

..Cells(Rows.Count,"C").End(xlUp)(2) = TextBox2.Text

HTH

"jeramie" wrote:

this code was working fine yesterday. at least i think i remember it working
as i finished a 20hr shift. any ways... it isn't now, and i have no idea
why. It is supposed to add a name and number from a userform to a list on
sheet2. Now it overwrites row 2 in either sheet, depending on which is active
when i run the userform.

any advice would be great.

Thanks in advance

Private Sub CommandButton2_Click()
With ActiveWorkbook.Worksheets("sheet2")
If TextBox1.Text < "" And Not .Range("A:A").Find(TextBox1.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's name already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("A:A").End(xlUp)(2).Select
Application.Selection.Value = TextBox1.Text
Cancel = False
If TextBox2.Text < "" And Not .Range("C:C").Find(TextBox2.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's Number already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("C:C").End(xlUp)(2).Select
Application.Selection.Value = TextBox2.Text
Cancel = False
End If
End If
End With

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default trouble adding to list.

thanks a bunch toppers!


"Toppers" wrote:

Hi,


Change:

Range("A:A").End(xlUp)(2).Select
Application.Selection.Value = TextBox1.Text

to
.Cells(Rows.Count, "A").End(xlUp)(2) = TextBox1.Text

and repeat ...

.Cells(Rows.Count,"C").End(xlUp)(2) = TextBox2.Text

HTH

"jeramie" wrote:

this code was working fine yesterday. at least i think i remember it working
as i finished a 20hr shift. any ways... it isn't now, and i have no idea
why. It is supposed to add a name and number from a userform to a list on
sheet2. Now it overwrites row 2 in either sheet, depending on which is active
when i run the userform.

any advice would be great.

Thanks in advance

Private Sub CommandButton2_Click()
With ActiveWorkbook.Worksheets("sheet2")
If TextBox1.Text < "" And Not .Range("A:A").Find(TextBox1.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's name already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("A:A").End(xlUp)(2).Select
Application.Selection.Value = TextBox1.Text
Cancel = False
If TextBox2.Text < "" And Not .Range("C:C").Find(TextBox2.Text,
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This Officer's Number already exists on file. "
TextBox1.Text = Clear
Cancel = True
Else
Range("C:C").End(xlUp)(2).Select
Application.Selection.Value = TextBox2.Text
Cancel = False
End If
End If
End With

End Sub

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
Trouble adding timesheet formulas Leo Excel Worksheet Functions 1 December 28th 09 09:56 PM
trouble adding addins jc Excel Discussion (Misc queries) 0 December 23rd 09 12:15 AM
trouble adding addins jc Excel Discussion (Misc queries) 0 December 23rd 09 12:13 AM
Trouble adding or subtracting from the current month Dave L[_2_] Excel Discussion (Misc queries) 10 October 9th 07 08:00 AM
I am having trouble adding a row in Excel. What am i doing wrong? Glendie Excel Worksheet Functions 1 May 28th 05 08:37 PM


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