1

I'm just starting out - 2 days into learning python. Trying to automate data entry in user form by reading from excel sheet.

I used the code below but am unable to run this loop for every row.

n=1 
    for n in range(n, sheet.max_column): #loop till last column in excel
        pyperclip.copy(str(sheet.cell (row=1, column=n+1).value)) #copy cell content column wise in clip board
        pyautogui.typewrite(pyperclip.paste()) #paste to citrix application user form
        keyboard.press_and_release('\t') #tab to shift to enter next form data

    keyboard.press_and_release('enter') #new form opened

the data read from excel sheet is :

enter image description here

the data is copied to clip board and pasted to citrix application - data form.

Data in one row represents the data to be copied column wise in data form - 1.

the loop is required to fill data form up to 'n' rows column wise for 'n' forms.

How can i modify the loop above ?

Simply Ged
  • 8,250
  • 11
  • 32
  • 40
hvst
  • 13
  • 4

1 Answers1

0

replaced the above code with below :

max_row=sheet.max_row
max_column=sheet.max_column

for i in range(3,max_row+1):
    for j in range(1,max_column+1):
        cell_obj=sheet.cell(row=i,column=j)
        pyperclip.copy(str(cell_obj.value))
        pyautogui.typewrite(pyperclip.paste())
        keyboard.press_and_release('\t')
    keyboard.press_and_release('\n')

works like intended !

hvst
  • 13
  • 4