Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default show result in msg box

I created a macro which checks for duplicates entries:
I would like the macro to display a message box with the name found and then
requst if wanted to be deleted. I can't seem to be able to put in the name in
the msgbox.

thanks, jared

Sub Check_4_Dups()
Dim first As String
Dim Second As String
Dim i As Integer
Dim Response


For i = 3 To 52
first = Cells(i, 4).Value
If first < "Employee's Name" Then
For n = i + 1 To 52
Second = Cells(n, 4).Value
If Second < "Employee's Name" Then
If first = Second Then Response = MsgBox("The Name "
&First& "Appears Twice, Do you want to delete one entry?", vbYesNo, "Check
for Duplicate names")
If Response = vbYes Then Cells(n, 4) = "Employee's Name"
End If
Next n
End If
Next i
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 510
Default show result in msg box

Hi,

It looks as if your "Employee's Name" is a variable which is not
defined ...

HTH
Carim

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default show result in msg box

"employee's name" is not a variable, "first" is the variable. Wherever a name
is not listed
it doesn't show a blank space, it shows "employee's name"
i hope that covers your question.

jared



"Carim" wrote:

Hi,

It looks as if your "Employee's Name" is a variable which is not
defined ...

HTH
Carim


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default show result in msg box

Worked fine for me, but this is more efficient

Sub Check_4_Dups()
Dim first As String
Dim i As Long
Dim Response

For i = 3 To 52
first = Cells(i, 4).Value
If first < "Employee's Name" Then
If Application.CountIf(Range("D3", Cells(i, 4)), first) 1 Then
Response = MsgBox("The Name " _
& first & " appears Twice, Do you want to delete
one entry?", _
vbYesNo, "Check for Duplicate names")
If Response = vbYes Then Cells(i, 4) = "Employee's Name"
End If
End If
Next i
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jared" wrote in message
...
"employee's name" is not a variable, "first" is the variable. Wherever a

name
is not listed
it doesn't show a blank space, it shows "employee's name"
i hope that covers your question.

jared



"Carim" wrote:

Hi,

It looks as if your "Employee's Name" is a variable which is not
defined ...

HTH
Carim




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default show result in msg box

That's Right.
I did not know exactly how to make a Countif formula for this one.

But Thanks

"Bob Phillips" wrote:

Worked fine for me, but this is more efficient

Sub Check_4_Dups()
Dim first As String
Dim i As Long
Dim Response

For i = 3 To 52
first = Cells(i, 4).Value
If first < "Employee's Name" Then
If Application.CountIf(Range("D3", Cells(i, 4)), first) 1 Then
Response = MsgBox("The Name " _
& first & " appears Twice, Do you want to delete
one entry?", _
vbYesNo, "Check for Duplicate names")
If Response = vbYes Then Cells(i, 4) = "Employee's Name"
End If
End If
Next i
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jared" wrote in message
...
"employee's name" is not a variable, "first" is the variable. Wherever a

name
is not listed
it doesn't show a blank space, it shows "employee's name"
i hope that covers your question.

jared



"Carim" wrote:

Hi,

It looks as if your "Employee's Name" is a variable which is not
defined ...

HTH
Carim





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
"1235" appears as "One thousand two hundred thirty five" H. Kan Excel Discussion (Misc queries) 11 December 8th 06 07:56 PM
spell number JAWAD CHOHAN Excel Worksheet Functions 1 December 12th 05 05:58 PM
Convert number into words Blackwar Excel Discussion (Misc queries) 4 December 2nd 05 12:05 PM
convert numbers to text bellman Excel Discussion (Misc queries) 0 October 4th 05 10:28 PM
convert value in word. For Exampe Rs.115.00 convert into word as . Shakti Excel Discussion (Misc queries) 1 May 10th 05 12:00 PM


All times are GMT +1. The time now is 10:36 AM.

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"