How to entre 1 st date of every month in different columns of same row in Excel file using UiPath

How to entre 1 st date of every month in different columns of same row in Excel file using UiPath [studio] coding. which acitvites should i use for this code? for sample i am attaching the image i have filed for jan & feb month and now i want to fill for rest of months in columns - H, I,J, K,L M N O & P for all 12 months
!

Hi,

You can loop through columns and based on cell positions, and you can use write cell activity to enter the dates

Can you explain it more which loop to be used based on cell positions. i don’t want to hard code it , it should take dates automatically so what should i write in write cell acitivity ?

hi @raghav.bhardwaj.external ,

The loop being referred would be something like:

for each "Column" in Dt_yourDatatable.Columns

Iterating each column, will also give you an index (coming from the ForEach variable) - this index is 0 based (Remember to add a +1, as on the example below, since month 0 would give an error)

You can then write in the cell, the dynamic value for the month by using the forEach Index:

Inside the forEach:

  • Write Cell Activity
    Parameters: Cell = Convert.ToChar(int_Index+1 + 64)+"1"
    Value = New DateTime(now.year,int_Index+1,1).tostring("MM/dd/yyyy")

image

This way the int_Index will change for each iteration, and so will do the month.

“For each” parameters:
image

Edit: Showing the values provided by the formulas above for 10 columns:

image

Duplicate :

1 Like