Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Help with a Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Help with a Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Help with a Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Help with a Macro

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Help with a Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"