Question

I have an Excel sheet and I need to generate diagonally 1-100 number

  • 5 August 2022
  • 4 replies
  • 87 views

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

4 replies

Badge +3

Hi @Naveen Kumar​ , For this you could use this approach.

  1. Open Excel file (advanced or basic)
  2. assign number 1 to a number variable
  3. convert this number to a string using the "to number" activity
  4. place a "go to cell" activity and provide A1 as "specific cell"
  5. place a "set cell" activity and as "value to set" use the converted number variable (type string)
  6. place a loop and choose "for n times" - n = 99
    1. increment the number variable by 1
    2. convert the number to a string variable as you've done it outside the loop
    3. inside the loop place the activity "go to cell" and choose 'active cell: one cell to the right'
    4. place another "go to cell" and choose 'active cell: one cell below'
    5. place a "set cell" activity and use the 'active cell' - as 'value to set' you can set the number variable (as string)
  7. 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.
Userlevel 4
Badge +7

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