I have an Excel sheet and I need to generate diagonally 1-100 number
In Excel sheet diagonally I have to generate numbers from 1 to100.could you please help on this scenario.
Example: 1st column 1st cell should be 1
2nd column 2 cell should be 2
3rd column 3 cell should be 3
Example: 1st column 1st cell should be 1
2nd column 2 cell should be 2
3rd column 3 cell should be 3
![Collaborator Silver Badge](https://uploads-us-west-2.insided.com/automationanywhere-en/attachment/39d17670-cf25-4e5f-a570-cb74d0dadb49_thumb.png)
Hi @Naveen Kumar , For this you could use this approach.
- Open Excel file (advanced or basic)
- assign number 1 to a number variable
- convert this number to a string using the "to number" activity
- place a "go to cell" activity and provide A1 as "specific cell"
- place a "set cell" activity and as "value to set" use the converted number variable (type string)
- place a loop and choose "for n times" - n = 99
- increment the number variable by 1
- convert the number to a string variable as you've done it outside the loop
- inside the loop place the activity "go to cell" and choose 'active cell: one cell to the right'
- place another "go to cell" and choose 'active cell: one cell below'
- place a "set cell" activity and use the 'active cell' - as 'value to set' you can set the number variable (as string)
- Close the excel file
Thanks for your valuable inputs ROBIN
Thanks for the quick reply Ashwin.
Please suggest without vb script. I want to implement it in automation anywhere only.
Please suggest without vb script. I want to implement it in automation anywhere only.
Hi @Naveen Kumar ,
You can either achieve it using the Click and Drag Excel Actions available in Automation 360, or you can use VBScript to achieve it:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set wb =objExcel.Workbooks.Add
Set ws = wb.Worksheets(1)
For i = 1 To 100
ws.Cells(i,i) = i
Next
wb.SaveAs("FilePathGoesHere")
objExcel.Quit
Set objExcel = Nothing
Kind Regards
Ashwin A.K
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.