How do i Convert VBA code to Google sheets app script

Report
Posts
1
Registration date
Thursday September 23, 2021
Status
Member
Last seen
September 23, 2021
-
I have been using Excel VBA code since couple of months and it was working fine now i have to move this code to Google Sheets to access it from anywhere.

I am not an expert but i tried hard to convert this VBA code to Google App script but its still not working.

The code is very simple in VBA but difficult one is in Google Sheets for me. I was hoping to get some help for it.

VBA

Private Sub worksheet_Change(ByVal Target As Range)
'Variables
On Error Resume Next
Dim dblWert As String
Dim strCellAdresse As String
'Define the area to be evaluated
If Not Application.Intersect(Target, Range("E7:E32")) Is Nothing Then
'Transfer cell address
strCellAdresse = Target.Address
'Change column E to F.
strCellAdresse = Replace(strCellAdresse, "E", "F")
'Remove dollar sign
strCellAdresse = Replace(strCellAdresse, "$", "")
'Pass value to variable
dblWert = Range(strCellAdresse).Value
'Format cell
'Pass variable to cell
Range("D38").Value = Format(dblWert, "#,##0.00 €")
End If
End Sub


Google App Script

function Toworkon(){
var Exsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Expiriment");
var Exrange = Exsheet.getRange('E7:E32').getValues();
//'Change column E to F.
Rngrplc = Replace(Exrange, "E", "F");
//'Remove dollar sign
Rngrplc = Replace(Exrange, "$", "")
// 'Format cell
// 'Pass variable to cell
var cell = Exsheet.getRange("D38").getValues();
cell.setNumberFormat("#,##0.00 €");
}