Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
Excel Username Macro

Could someone please help me out with a macro for Excel 2007. I have trying to combine a few columns to create a username (please see attached excel file).
The username would need to be the first four letters of the first name, first letter of the last name, birth month ""2digit"", birth day ""2digit"")"
Example:
First Name: William
Last Name: Smith
Birth Date: 3/20/2001
Username: WILLS0320
Thanks
Randy
Attachment:UsernameMacro.xls
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily
I could not open your xls file. Anyway Assume the data is put as follows in your xls file
A1 cell in excel sheet : William
A2 cell in excel sheet: Smith
A3 Cell in excel sheet:3/20/2001
A4 cell in excel sheet: WILLS0320
'Function using for First four letters of the first name:
Range("A5")= left(Range("A1") ,4)
'Function using for first letter of last name
Range("A6")=left(Range("A2"),1)
'Function using for the 2 digits of birth month
range("A7")= range("A3")
range("A7").numberformat="MM" ' for 2 digit format
'Function using for the 2 digtis of birthday day
range('A8")=range("A4")
range("A8").numberformat="DD" 'for 2 digit format
Probably it works easily