Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Login Macro, (Inputbox & MsgBox)..Need help with a counter.
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Login Macro, (Inputbox & MsgBox)..Need help with a counter.
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) -- steveB Remove "AYN" from email to respond "Max via OfficeKB.com" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help with InputBox and MsgBox | Excel Discussion (Misc queries) | |||
Help with InputBox and MsgBox | New Users to Excel | |||
msgbox / inputbox etc | Excel Discussion (Misc queries) | |||
msgbox / inputbox etc | Excel Worksheet Functions | |||
msgbox / inputbox etc | Setting up and Configuration of Excel |