I'm using this function to read a certain set of data in a hidden Sheet1
to do encryption based on the selection by the user. It's all working fine, but its kinda slow, I need to apply this to 160.000 rows.
ATM it goes through every letter of every word of every selected range.
(Function below is used to encrypt letters, based on the "data set" in the hidden Sheet1
.)
Public Function enc_Letter(mtext As String)
Dim mChr As String
Dim mResult As String
For i = 1 To Len(mtext)
mChr = Mid(mtext, i, 1)
For j = 1 To 53
If j = 53 Then
mResult = "Encryption_Error"
GoTo err
End If
If mChr = Sheet1.Cells(j, 1) Then
mResult = mResult & Sheet1.Cells(j, 2)
Exit For
End If
Next j
Next i
err:
enc_Letter = mResult
End Function
Edit: I have added the Sub mabye this helps in finding a solution:
Sub LetEnc()
Dim mrange As Range
Dim mtext As String
On Error GoTo errHandler
Set mrange = Application.InputBox("Select cells to encrypt", , , , , , , 8)
If Not mrange.HasFormula Then
mrange.Value = Trim(mrange.Value)
End If
errHandler:
If err.Number = 424 Then
Exit Sub
End If
Dim ss As Range
For Each ss In mrange
ss.NumberFormat = "@"
mtext = ss.text
ss = enc_Letter(mtext)
Next ss
End Sub
That's not encryption.
is incorrect. See en.wikipedia.org/wiki/Substitution_cipher . It is just a weak encryption. Nevertheless you are correct about the rest of your statement. \$\endgroup\$