Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
1) I have created a small macro where in it asks for my user ID when ever I run this. I am not unable to run this macro. 2) If I am not giving the user ID in the prompt box then the macros should end with the message as cancelled. 3) I need to set a format for the user id, it contains two alphabets and 6 numbers and I need to restrict to the format. For Ex: AA123456. I do not know how to write the macros's for this format. Kindly let me know how to do. Range("C1").Select ActiveCell.FormulaR1C1 = "Date" Range("C2").Select = InputBox(Prompt:="Quickook") If ID = True Then Range("c3").Select If ID = False Then End MsgBox "Cancelled" End Sub Regards, Igneshwara reddy. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try something like this:
Function pwdValid(pwd As Variant) As Boolean pwdValid = True If Not Len(pwd) = 8 Then pwdValid = False Exit Function End If For i = 1 To Len(pwd) Select Case i Case 1, 2 If Not UCase(Mid(pwd, i, 1)) Like "*[A-Z]*" Then pwdValid = False Exit Function End If Case Else If Not Mid(pwd, i, 1) Like "*[0-9]*" Then pwdValid = False Exit Function End If End Select Next i End Function -- Dan On Jun 16, 9:33*am, Igneshwara reddy wrote: Hi, 1) I have created a small macro where in it asks for my user ID when ever I run this. I am not unable to run this macro. 2) If I am not giving the user ID in the prompt box then the macros should end with the message as cancelled. 3) I need to set a format for the user id, it contains two alphabets and 6 numbers and I need to restrict to the format. For Ex: AA123456. I do not know how to write the macros's for this format. Kindly let me know how to do. Range("C1").Select * * ActiveCell.FormulaR1C1 = "Date" * * Range("C2").Select = InputBox(Prompt:="Quickook") * * If ID *= True Then * *Range("c3").Select * * If ID *= False Then * * End * * MsgBox "Cancelled" End Sub Regards, Igneshwara reddy. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another approach:
Sub test() Dim ID As String ID = InputBox("Who da man:") MsgBox ID Like "[A-Z][A-Z]######" End Sub HTH. Best wishes Harald "Igneshwara reddy" wrote in message ... Hi, 1) I have created a small macro where in it asks for my user ID when ever I run this. I am not unable to run this macro. 2) If I am not giving the user ID in the prompt box then the macros should end with the message as cancelled. 3) I need to set a format for the user id, it contains two alphabets and 6 numbers and I need to restrict to the format. For Ex: AA123456. I do not know how to write the macros's for this format. Kindly let me know how to do. Range("C1").Select ActiveCell.FormulaR1C1 = "Date" Range("C2").Select = InputBox(Prompt:="Quickook") If ID = True Then Range("c3").Select If ID = False Then End MsgBox "Cancelled" End Sub Regards, Igneshwara reddy. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Harald,
This quite ok, but the results is displayed as False. Whatever the data I enter it should be displayed in cell (C2) but that is not showing up now and moreover the length of characters should be restricted to 8 if not the function should exit without running the macro. EX: the data will be as AA11111 Let me know if any other options available. Regards, Igneshwara reddy. "Harald Staff" wrote: Another approach: Sub test() Dim ID As String ID = InputBox("Who da man:") MsgBox ID Like "[A-Z][A-Z]######" End Sub HTH. Best wishes Harald "Igneshwara reddy" wrote in message ... Hi, 1) I have created a small macro where in it asks for my user ID when ever I run this. I am not unable to run this macro. 2) If I am not giving the user ID in the prompt box then the macros should end with the message as cancelled. 3) I need to set a format for the user id, it contains two alphabets and 6 numbers and I need to restrict to the format. For Ex: AA123456. I do not know how to write the macros's for this format. Kindly let me know how to do. Range("C1").Select ActiveCell.FormulaR1C1 = "Date" Range("C2").Select = InputBox(Prompt:="Quickook") If ID = True Then Range("c3").Select If ID = False Then End MsgBox "Cancelled" End Sub Regards, Igneshwara reddy. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I was only trying to show how you can ensure that a string has two uppercase
letters followed six digits. AA11111 has five digits only, so it will return false. Why do you want an invalid ID entry in a cell ? There are multiple problems with the code you posted, I don't know what it is supposed to do or where to start. But see if this gets you going: Sub test() Dim ID As String ID = InputBox("Who da man:") If ID = "" Then Exit Sub 'cancelled If ID Like "[A-Z][A-Z]######" Then Range("C2").Value = "Yo da man" Range("D2").Value = "as accepted on " & now Else Range("C2").Value = "Denied" Range("D2").value = "Formatting C:\ -please wait..." Beep End If End Sub Now test this using two uppercase letters and SIX digits ;-) Best wishes Harald "Igneshwara reddy" wrote in message ... Hi Harald, This quite ok, but the results is displayed as False. Whatever the data I enter it should be displayed in cell (C2) but that is not showing up now and moreover the length of characters should be restricted to 8 if not the function should exit without running the macro. EX: the data will be as AA11111 Let me know if any other options available. Regards, Igneshwara reddy. "Harald Staff" wrote: Another approach: Sub test() Dim ID As String ID = InputBox("Who da man:") MsgBox ID Like "[A-Z][A-Z]######" End Sub HTH. Best wishes Harald "Igneshwara reddy" wrote in message ... Hi, 1) I have created a small macro where in it asks for my user ID when ever I run this. I am not unable to run this macro. 2) If I am not giving the user ID in the prompt box then the macros should end with the message as cancelled. 3) I need to set a format for the user id, it contains two alphabets and 6 numbers and I need to restrict to the format. For Ex: AA123456. I do not know how to write the macros's for this format. Kindly let me know how to do. Range("C1").Select ActiveCell.FormulaR1C1 = "Date" Range("C2").Select = InputBox(Prompt:="Quickook") If ID = True Then Range("c3").Select If ID = False Then End MsgBox "Cancelled" End Sub Regards, Igneshwara reddy. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |