# Dynamo Excel-Export Loop

**URL:** <https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047>\
**Category:** Revit\
**Tags:** excel\
**Created:** [August 29, 2019, 7:52am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047 "2019-08-29T07:52:31Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 29, 2019, 7:52am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/1 "2019-08-29T07:52:31Z")

</div>

Hello World of Dynamo.

I am trying my best on looping an excelExport but am not able to do so yet.

There are 4 numbers in each name of the List.

- get all List-items 0001 to 0099 and export them to Excel (startRow 10)
- get all List-items 0101 to 0199 and export them to Excel (startRow 20)
- get all List-items 0200 to 0299 and export them to Excel (startRow 30)
- (…)
- get all List-items 9901 to 9999 and export them to Excel (startRow 1000)

I hope you can help me out with that issue - thanks in advance. 🙂

Here’s what i got atm:

 ![PNG](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/3/b3f3c832924905dfc50927591c4d2b02cab6a586.jpeg)

---

<div class="post-metadata">

**Author:** ![Tomasz](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/tomasz/32/66785_2.png) [@Tomasz](https://forum.dynamobim.com/u/Tomasz)\
**Post date:** [August 29, 2019, 8:11am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/2 "2019-08-29T08:11:15Z")

</div>

It’s not exactly clear to me what you are trying to achieve.  
If the goal is to have different lists saved in different columns or rows - here’s my take on this.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/e/5ea70b58d28c73d05a7149f6530cfddec0134029.png)

[Excel.dyn](https://forum.dynamobim.com/uploads/short-url/wdPkxMn0tENkF24WBP5JZGNZ5f5.dyn) (24.5 KB)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/d/5dcc00c6a40e69a8698166c33d89e502e01f54bd.png)

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 29, 2019, 8:27am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/3 "2019-08-29T08:27:50Z")

</div>

Let me specify my problem:

The list to sort and split looks something like this.  
0001-testobject1-time  
0012-test objectR-time  
0178-test objectE-fast  
1189-test objectK-loop  
.  
.  
.  
9942-testobjectY-answer

Now this list should be sorted as follows and exported to Excel:  
0001-0099 one line at a time  
then 10 lines spacing  
0101-0199 one line each  
then 10 lines spacing  
and so on until 9901-9999.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 29, 2019, 9:50am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/4 "2019-08-29T09:50:35Z")

</div>

Try to add a \*10 to the results of the range node in the example given.

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 29, 2019, 12:47pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/6 "2019-08-29T12:47:31Z")

</div>

The idea is brilliant and I wish it would work. Unfortunately the Script doesn’t write every single list to a “new” start row but tries to export all lists to every start value instead. This ends in a bunch of incomplete lists and one (the last one) complete list - which isn’t seperated by empty rows as well.

 ![PNG](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/a/ca47b5c228e847b522e35bc27cc7ab01dde5ed79.jpeg)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 29, 2019, 1:03pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/7 "2019-08-29T13:03:18Z")

</div>

Levels and lacing. 🙂

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 29, 2019, 2:02pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/8 "2019-08-29T14:02:46Z")

</div>

Hey Jacob, thank you for another quick response. Since i’m new to Dynamo, could you please elaborate on your answer? I know where to make these settings, but I’m not sure if I understood the exact use of it 😕

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 29, 2019, 3:00pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/9 "2019-08-29T15:00:29Z")

</div>

Try using shortest lacing on the Data.ExportExcel node. Then set the levels to @L3 (might be @L2 - I am on vacation so i cannot test it myself). If that doesn’t work try longest lacing for data and column inputs, same levels.

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 30, 2019, 8:02am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/10 "2019-08-30T08:02:49Z")

</div>

Shortest lacing with @L3 worked, thanks a lot 🙂  
Unfortunately there is no separation between the 100 steps. If I can fix this with some help, I would be very very happy.

I would like to tell him:  
Start 0-99 in line 0  
Start 100-199 in line 10 (or 2 or 30)  
Start 200-299 in line 20 (or 4 or 60)  
and so on.

Thanks for helping me out despite your vacation. I hope you have a great time. 😌

 ![Loop3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/f/ef0e9aa6cc2bdd9a3af058f6797b84f5d87cc427.png)

---

<div class="post-metadata">

**Author:** ![Andrew\_Hannell](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andrew_hannell/32/103315_2.png) [@Andrew\_Hannell](https://forum.dynamobim.com/u/Andrew_Hannell)\
**Post date:** [August 30, 2019, 9:04am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/11 "2019-08-30T09:04:44Z")

</div>

@ChrisWithRevit

Is the objective just to produce an array of numbers in a particular format in Excel- or is there some dependency on Revit or model data ?

If the former- you’d probably be better off with an Excel macro.  
The below is a very simple example- if you wanted to adjust the number ranges, you could create a function with arguments and have an input form i.e. you just input the start or finish numbers on a form

```
Sub CreateNumberArray()
   
   'row 1
With Sheet1.Range("a1")
    .Value = 0
    .AutoFill .Resize(1, 100), xlFillSeries
End With
    
'row 2
With Sheet1.Range("a3")
    .Value = 100
    .AutoFill .Resize(1, 100), xlFillSeries
End With
    
'row 3
With Sheet1.Range("a5")
    .Value = 200
    .AutoFill .Resize(1, 100), xlFillSeries
End With

'row 4
With Sheet1.Range("a7")
    .Value = 300
    .AutoFill .Resize(1, 100), xlFillSeries
End With

End Sub

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/c/acc1d9606c32ed6f2802e45955399d3de47e22ed.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 30, 2019, 10:18am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/12 "2019-08-30T10:18:28Z")

</div>

> [@ChrisWithRevit](#):
>
> Unfortunately there is no separation between the 100 steps. If I can fix this with some help, I would be very very happy.

Post an image of the dyn. 🙂

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [August 30, 2019, 11:19am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/13 "2019-08-30T11:19:23Z")

</div>

Atm it looks like that:

 ![Loop4](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/3/73fa33e449bc24acdf4b540885067bba554898d7.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [August 30, 2019, 1:47pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/14 "2019-08-30T13:47:24Z")

</div>

Try startCol @L1.

---

<div class="post-metadata">

**Author:** ![ChrisWithRevit](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@ChrisWithRevit](https://forum.dynamobim.com/u/ChrisWithRevit)\
**Post date:** [September 2, 2019, 9:56am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/15 "2019-09-02T09:56:55Z")

</div>

Not working. The Export always uses startCol 0 and no more input than that.

---

<div class="post-metadata">

**Author:** ![dustin.gilliam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dustin.gilliam/32/79534_2.png) [@dustin.gilliam](https://forum.dynamobim.com/u/dustin.gilliam)\
**Post date:** [September 4, 2019, 6:31pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/16 "2019-09-04T18:31:12Z")

</div>

I was able to accomplish your desired outcome using the BBData node and the Write Excel node from the bumblebee package. I had to take the resulting lists from List.Chop and get the data at each index and feed it into a BBData node along with the sheet name and starting cell. Not sure I did it the most efficient way but the result was as intended.

 ![EXCEL%20WRITE%20EXAMPLE%20DYN](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/e/0e2e8d59bbf29ea069defda68c09f387cbde6b03.jpeg)

![EXCEL%20WRITE%20EXAMPLE](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/3/33997b416870216f4550fb14a7ab1ec4741853cc.jpeg)

Edit: Here is the file I made. [EXCEL WRITING TEST.dyn](https://forum.dynamobim.com/uploads/short-url/peMIeIZKoXd24zU7iMqQl8dFJTI.dyn) (40.6 KB) I ran this in Dynamo 1.3.2.2480 via Revit 2018.

---

<div class="post-metadata">

**Author:** ![Congzheng](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@Congzheng](https://forum.dynamobim.com/u/Congzheng)\
**Post date:** [April 13, 2021, 3:41pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/17 "2021-04-13T15:41:48Z")

</div>

Hi, I would like to contribute a little for this topic.

Does “Contains” node support multiple search?  
I will need to search different parameters from different sheets, but need to keep their structure for the next step. Now it is only two sheets, but the purpose is to be able to search for multiple parameters from multiple sheets.

 ![QuestionForForum_ContainsNode](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/a/8a41403c4c13eb6e53ec75e07bace77eedf16c43.jpeg)

This is a development for the colleagues, so I’m using Dynamo Studio 2017 since it is not updating every year. if following Revit Dynamo, I will need to rewrite the script every year. (there are many obsolete Dynamo scripts in the repository, the fact is that no one is willing to update them. )

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [April 13, 2021, 6:10pm UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/18 "2021-04-13T18:10:41Z")

</div>

> [@Congzheng](#):
>
> if following Revit Dynamo, I will need to rewrite the script every year.

Moving to Dynamo 2.0 means a graph like this (most of them in fact) will run in any Dynamo Revit version from 2017 to 2022. Dynamo Studio is capped at Dynamo 1.3.4, which is missing about 3 years of updates.

---

<div class="post-metadata">

**Author:** ![Congzheng](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@Congzheng](https://forum.dynamobim.com/u/Congzheng)\
**Post date:** [April 14, 2021, 7:54am UTC](https://forum.dynamobim.com/t/dynamo-excel-export-loop/40047/19 "2021-04-14T07:54:55Z")

</div>

Thanks for pointing out. I will need to convince my colleagues to keep learning Dynamo 😆
