A Login Macro, (Inputbox & MsgBox)..Need help with a counter.

  • Thread starter Max via OfficeKB.com
  • Start date
M

Max via OfficeKB.com

Hi,

i written a macro where an inputbox retrives the user's name,
and then a welcome msg to the user is then displayed in a msgbox..

The names of the user's who enter their name in this login inputbox,
is compiled into row1 of a spreadsheet...

i was wondering if anyone could help tell me how i could,
take the data entry and ensure it doesnt repeat itself while it adds
to the rows...
example :- if the the macro below is used and the name Tim is used
3 times, it will appear from cell a1-a3 in the spreadsheet..

i was wondering how i could make it so that the names wont be repeated,
and a counter can be added on the next row of each name entry.

Basically i want my macro to be able to compile a list of users and the
number of times they logged in... not having duplicate entries as well..

could someone view my coding below n advice?

thanks awhole lot..!

______________________________________________________________

Sub Login()
Dim Msg, Response
Dim Name As String

Name = InputBox("Enter Your Name")
Msg = "Welcome " & Name
Response = MsgBox(Msg)


Row = 1
ThisCell = Sheets("sheet1").Cells(Row, 1)
Do While ThisCell <> ""
Row = Row + 1
ThisCell = Sheets("sheet1").Cells(Row, 1)
Loop
Sheets("sheet1").Cells(Row, 1) = Name

End Sub
 
S

STEVE BELL

After the input box steps, add the following

======================================================================
If WorksheetFunction.CountIf(Name, Columns('input column number where names
are stored')) > 0 then
' code to add count to existing name in list
Else
' code to add name to list
End If
==================

If the name list is in a single row:
If WorksheetFunction.CountIf(Name, Rows('input column number where names are
stored')) > 0 then


to add count to an existing cell
Range("A1").Value = Range("A1").Value + 1

to find the row containing Name:
use a find function or a match function (in code)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top