Roberto Negro
Roberto Negro

Reputation: 1

Excel vba 16.65 mac osx cannot write string with special characters to a table cell

I have a table where I store user password in column 2 ("Password"). I have created a simple routine that encrypts with some special characters the original password string. If I take the routine output and I manually paste it into the table cell, everything is working ok. When I try to do it programmatically, the old non encrypted value stays there unchanged.

...
Set tblUtenti = Tabelle.ListObjects("Utenti_Tabella")
...
tblUtenti.DataBodyRange.Value2(UtenteRecNo, 2) = NuovaPwd
...

Any solution?

Upvotes: 0

Views: 76

Answers (1)

FunThomas
FunThomas

Reputation: 29592

Your problem has nothing to do with special characters or MacOS. Your syntax of accessing the cell is wrong:

The statement tblUtenti.DataBodyRange.Value2(UtenteRecNo, 2) is reading all values of the table (DataBodyRange) into a 2-dimensional array. After that you modify one of the values inside the array. However, the array is no longer attached to the table itself, so the new value is not put into the cell.

Simply change the line to tblUtenti.DataBodyRange(UtenteRecNo, 2).Value2 = NuovaPwd

Upvotes: 2

Related Questions