ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   vba/macro code (https://www.excelbanter.com/new-users-excel/270323-vba-macro-code.html)

JSHARP92

vba/macro code
 
ive been given instructions to create a macro which will be used on a form to add a new user to a system. Could somebody please help me with writing out this code? the steps are below, thank you to anybody who helps me with this


Create a macro that will add the username and password to the UserDetails worksheet. You will need to include code for the following stages:

* Declare the variables that you need. (Row, RowNum, NumUsers as Integer and Cellref, Cellref2, pword and uname as String)
* Assign values to the NumUser, pword and uname variables from the named ranges on the worksheet.
* Store the value 1 in the RowNum variable.
* Move to the UserDetails worksheet.
* Start a For Next loop that loops from 1 to NumUsers. (For Row = 1 to NumUsers)
* Generate the cell references for username and password and store these in variables. (you need two)
* Use an If statement to enter the password and username into the first available row, move back to the log in form and display a confirmation message if the cell is empty and and adds 1 to the Row Number if it is not empty.
* Loops to next row. (Next Row)


All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com