add yes no

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
good evening,

I use the following:-

Sub Gencode()
Static IsRandomized As Boolean
Dim i As Integer, PW1 As String
Dim cell As Range, PW As String




With Sheets("code") ' Change Code to the name of the sheet this is to work on.
.Unprotect








If Not IsRandomized Then Randomize: IsRandomized = True

For Each cell In .Range("b3:b200")
PW = vbNullString
For i = 1 To 8
Do
DoEvents
PW1 = Chr(Int((97 - 122 + 1) * Rnd + 122)) ' Lower case alpha
Loop Until InStr(1, PW, PW1, 1) = 0
PW = PW & PW1
Next i
PW = Replace(PW, Mid(PW, Int(8 * Rnd + 1), 1), Int(8 * Rnd + 1))
cell.Value = PW
Next cell




.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False, AllowFormattingCells:=True
End With
End Sub


I am trying to insert a 'Yes/No' message box

Message "This Will Reset Your Previous Generated Codes, Do You Want To Save The File 1st Then Generate New Codes Or Just Generate New Codes?"

If Yes, then save the file a selected location (rather than just IE c:\myfiles) and then generate new codes.

if no, just generate new codes

Having tried to do the above myself but my attempts has just caused a boat load of errors especially with wanting to save to a random location.

Hoping someone can help.
KR
Trevor3007
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Do you already have code for the saving part?
 
Upvote 0
hi there Norie,

thx for getting back to me. No I don't have
code for the saving part? Sorry.

KR
Trevor3007
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top