Help: Conversion VBA to Google Script.

Skip to first unread message

Vincent Wilkens

Nov 28, 2022, 10:59:10 AM11/28/22
to Google Apps Script Community
Is it possible to convert this into google script? If so could someone do it for me, help would be appreciated. 

Sub Select_All_Cells_with_Data()

Set rng = ActiveSheet.UsedRange

rng.Cells(1, 13).Select

For i = 1 To rng.Rows.Count
    For j = 13 To rng.Columns.Count
        If rng.Cells(i, j) <> "" Then
            Union(Selection, rng.Cells(i, j)).Select
        End If
    Next j
Next i

    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False

End Sub

Nov 28, 2022, 2:34:35 PM11/28/22

Try this:


function selectCellwithData()


  var sheet = SpreadsheetApp.getActiveSheet();

  var data = sheet.getDataRange().getValues();

  for (var i=0;i<data.length;i++)


    for (var j=0;j<data[i].length;j++)


      if (data[i][j] != "")




You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Reply all
Reply to author
0 new messages