The online racing simulator
Excel / VBA help!
(16 posts, started )
Excel / VBA help!
Hi all, whoever knows about Excel / VBA coding, please please add me on msn: [email protected]

There are a few functions I am having problems with, please help me

Thanks in advance

Brad
I guess you would get more help by asking specific questions here... Just saying that you need help is a bit pointless...
i know about excel coding, but i don't use msn, so i guess you are SOL











nah, i don't really know that much about excel coding, but my point is still valid
Ok, well im doing a project for my alevel course, ive already got a password code that opens when I click a button assigned to that macro, but I was looking for code that only allows 3 failed attempts, then closes MS Excel down. Thats the first thing...

Secondly, I have a sheet with a table of data in it, and I need code to export this data (by specifying the right cell range) to a MS Word template, so it can be neatly printed out, and archived.

Thats basically it, with the second request being the most urgent, because the password code I have now would be ok if I cant find a better alternative.

Thanks,

Brad
#5 - herki
Something like that?
You can PM me if you need further help/explanation, I consider myself pretty useable with VB(A)

Well, that's without 3 attempts, and not exporting anything to Word, but somehow a base for working
Attached files
HideSheet.zip - 11.3 KB - 125 views
Hi, thanks for the effort, but I have already got a password prompt im happy with in my system, I was just wondering if there is a way of modifying this code, so it only allows 3 attempts, then shows a warning box saying "You do not have access to this system, goodbye" or something along those lines, then the program closes?

The current password code is below:

Sub Password()

If InputBox(" Please Enter your Password", Title) = "letterbox" Then
Sheets("Front Page").Select

Else
If MsgBox("You have entered an invalid password", vbRetryCancel) = vbRetry Then
Password
Else
End If
End If

End Sub


Also, if anyone could try the export a data range to a word template, it would be brilliant

Thanks for your responses so far

Brad

EDIT: I can send you my current system, so you could get a better picture of what I need, and any other advice you have? Thanks.
Hi, thanks for that link, it was very useful, but I dont know how to transfer to another sheet, if the correct password is entered. The form is working nicely, but I need a bit of help linking it to another sheet, and programming a macro to open the form when a button is pressed.

the code is:


Dim Var1 As Integer

Private Sub CommandButton1_Click()
If Text2.Text <> "hello" Then
Select Case Var1
Case Is <= 2
If MsgBox("The password is incorrect", 5, "Incorrect Password") = vbCancel Then Unload Me

Var1 = Var1 + 1
Case Else
MsgBox "You have entered the incorrect password 3 times, login denied. The program will now terminate", vbCritical, "Locked Out"
Unload Me
End Select
Else
MsgBox "Correct password, access granted"
End If
End Sub

Private Sub CommandButton2_Click()
Unload Me
MsgBox "Login cancelled by user", vbExclamation, "Invalid Login"
End Sub


Please help Thanks in advance

Brad
Ok, Ive edited the code so it goes to Sheet 2 when the correct password is entered, but I cant find a code to close the form when it gets to the new page, cos otherwise it cant be closed without me clicking cancel... which closes the whole spreadsheet down.

This is the new code:

Dim Var1 As Integer

Private Sub CommandButton1_Click()
If Text2.Text <> "hello" Then
Select Case Var1
Case Is <= 2
If MsgBox("The password is incorrect", 5, "Incorrect Password") = vbCancel Then Unload Me

Var1 = Var1 + 1
Case Else
MsgBox "You have entered the incorrect password 3 times, login denied. The program will now terminate", vbCritical, "Locked Out"
Unload Me
End Select
Else
If MsgBox("Correct password, access granted", vbOK, "Access Granted") = vbOK Then Sheets("Sheet2").Select

End If
End Sub

Private Sub CommandButton2_Click()
Unload Me
MsgBox "Login cancelled by user", vbExclamation, "Invalid Login"
End Sub

Please help me, cos the deadline is only a few weeks away.

Thanks

Brad
Private Sub CommandButton1_Click()
retries% = 0
pass$ = "lfs"
inputpassword:
userinput$ = InputBox("Please enter the password to proceed", "zOMG HAX0RS!")
If userinput$ <> pass$ Then
retries% = retries% + 1
If retries < 3 Then
result = MsgBox("Wrong password!", vbCritical + vbRetryCancel, "zOMG HAX0RS!")
If result = vbRetry Then GoTo inputpassword Else GoTo quitapp:
Else
GoTo quitapp
End If
Else
MsgBox "success" 'stuff
GoTo exitsub
End If

quitapp:
MsgBox "quit" 'Application.Quit

exitsub:
End Sub

if you combine that with the one I attached above, you should be pretty much done

edit: or do you really want to stick with forms?
Yea ive done it now, thanks alot for your help everyone, much appreciated
Quote :Ok, well im doing a project for my alevel course

Is that the make-an-order-system-for-a-company assignment which I'm currently doing at A2? I find Excel/Office incredibly boring tbh and I'd much rather be doing something more general because all A-level ICT seems to do is create office monkeys and perpetuate Microsoft's hold of the market.
Yea it is... but we are doing it at AS, we do a harder project at A2 with access. And that is true, everything is about office, would be a bit more interesting I have to say, if we worked with something else, but, well thats life
Yeah, we've got an Access exam soon. It's stupidly easy.

I'm having real trouble doing the Excel evaluation (I can do the practical bit fine but suck at write-ups), can you give me some advice?
Hi sorry, just very quickly, Herki, you know the attachment you posted here first, you had this code in it:

Sheet2.Visible = xlSheetVisible: Sheet2.Activate

How can i reverse this, so I can make a log-off button, so it goes back to the entry sheet, but also re-locks and hides the other worksheets?

Thanks

Brad
Oops, sorry I figured out how to do this, this thread can be closed now if needed thanks all

Excel / VBA help!
(16 posts, started )
FGED GREDG RDFGDR GSFDG