--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/Gj_-camt-s8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/5f378600-ff8d-4ea7-a6aa-a1c3517fa22en%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CA%2BobnrFfG0p_E0vaZzuYcj_kv%3DSccuzCj89qh_yHx0HKpnK7Rw%40mail.gmail.com.
A: To convert the VBA code you provided to Google Apps Script, you can use the following code:
This code uses the SpreadsheetApp class to access the active sheet and the data range within that sheet. It then loops through the rows and columns of the data range and selects the cells that have data. Finally, it copies the selected cells and pastes their values and number formats back into the same cells.
Note that this code is not a direct translation of the original VBA code, as the concepts and methods used in Google Apps Script are slightly different from those used in VBA. However, it should produce the same result as the original code.
Can someone please convert this VBA macro to google app script pleaseSub Update_Current_Time() Dim sh As Worksheet Set sh = ActiveSheet '''' Validations'''''''''' Dim rng As Range Set rng = Selection If Application.WorksheetFunction.CountBlank(rng) <> 1 Then MsgBox "Incorrect range selection", vbCritical Exit Sub End If If rng.Row < 5 Or rng.Row > 35 Then MsgBox "Incorrect range selection", vbCritical Exit Sub End If If rng.Column < 2 Or rng.Column > 7 Then MsgBox "Incorrect range selection", vbCritical Exit Sub End If If sh.Cells(rng.Row, 1).Value <> Int(Now) Then MsgBox "You can update the time for today only", vbCritical Exit Sub End If
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/38f85b3a-04aa-4901-a0db-73121cb79fa3n%40googlegroups.com.