Write on a row depending the number of the day

Hi I am working on a excel file that looks like this


So I want to grite an info that I get from a webpage depending the number of the day
If is day 1 I write it on the row of day 1
I create it using the for each row activity with an if But I want to know if there is a more simple way to create this

1 Like

Hi @Juandix
You can utilise the DateTime.Day property to find the number of the day.

And to avoid using For loop, one option is to find the value in Excel, there are some already solved topics in forum for this, like How to find the value in excel - #6 by Palaniyappan

However, I really don’t think that’s necessary in your case since it’s a fixes sequence. You can just offset the Row by the difference in index (i.e. Day 1 is on Row 8, so offset the row value by 7 and you should be good to write directly on the row)

I hope this helps.

1 Like

Hi @Juandix

you dont need to change anything, as you have your workflow thats the correct way, just use linq if you are working with at least 1000+ rows

Regards!

1 Like

Do you use ForEachRow in DataTable? If the dates are always in order from 1, we can directly modify the target row, as the following.

Regards,

2 Likes

@Juandix you can maintain two datatables. One which contains your current data through add data row and second which contains previous days data. In the last you can merge both.

@Juandix

You need not use for loop…

As I see the numbers are in sequence starting from row 8

Ypu can use write cell with range property as "B" + (now.day+7).ToString will write in the B8 on the first day…B9 on second day and so on…

Similarly B can be replaced with other column names and can be used for other cells in that row

Hope this helps

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.