Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 3

Excel VBA code question

l need to write the VBA code to come up with a 2-character password in the format ‘LetterNumber’ (A-Z and 0-9) in cell G4. Examples of valid passwords include A5, M0, Z8, and so on in cell G4.

The correct password will change the text in cell G5 from “No” to “Yes”.

My code is followed:

Sub BruteForce()

Dim pw As String

Dim i As Integer

Do

ThisWorkbook.Sheets("Login").Cells(4, 7).ClearContents

For i = 1 To 2

If i Mod 2 = 0 Then

pw = pw & Int((9 - 0 + 1) * RND + 0)

Else

pw = pw & Chr(Int((90 - 65 + 1) * RND + 65))

End If

Next i

ThisWorkbook.Sheets("Login").Cells(4, 7).Value = pw

If ThisWorkbook.Sheets("Login").Cells(5, 7).Value <> "NO" Then

Exit Do

End If

Loop

End Sub

 

I can generate right format of password, but once with loop, my vba will stuck when I run!

pleas help me, I'll be really appreciated!

 

2 Replies
Highlighted
Community Manager
Message 2 of 3

Re: Excel VBA code question

Hi @Sherrylikeke,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our community organized so users can more easily find information.

As you’ll notice, your topic is now here in the Project Development Help and Advice board. No action is needed on your part; you can continue the conversation as normal here.

Cheers!


I hope this helps,
Andrea

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Ground Controller Lvl 2
Message 3 of 3

Re: Excel VBA code question

Hi @Sherrylikeke ,, what is Mod 2,,, seems is a variable,, and not getting satisfied within the Loop.

 

Rajesh S.