Subarray estrapolation

206 views
Skip to first unread message

Denis Dal Soler

unread,
Aug 14, 2022, 5:38:28 AM8/14/22
to Google Apps Script Community
Hi guys
I need to estrapolate a sub two dimensional array  (A)  from a bigger two dimensional array (B).
Normally I use  "FinalArray =Sourcearray.getDataRange().getValues()" but so I import all the source not a sub.
Thanks
Denis

Bruce Mcpherson

unread,
Aug 14, 2022, 8:42:25 AM8/14/22
to google-apps-sc...@googlegroups.com
Since you mention getDataRange(), by sourcearray I assume you mean from a sheet.

You can use getDataRange().offset() to define the part you need.


for example, say you wanted the column B & C & D rows 4 - 5

sheet.getDataRange().offset(3,1,2,3).getValues()

if sourceArray is really an array, then you could do this
const finalArray = sourceArray.slice (3,5).map(f=>f.slice(1,4))


--
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 google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/f6327018-7c56-4f66-9e60-3939e666b95en%40googlegroups.com.

Denis Dal Soler

unread,
Aug 15, 2022, 8:45:07 AM8/15/22
to google-apps-sc...@googlegroups.com
All perfect!
It runs!!
Thanks 

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/fJBNgfNhNUU/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/CANijH0XYG9uW%2B16i32h0tD%2BXYM3JAy%3DgaUbj9Wyyw43hwcUfqg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages