excel vba - What VBA coding in a Userform can I use to find a cell based upon row & column content, and then update that cell? -
i complete beginner vba, truely.
i trying create user form update number of tasks person completes on given date listed on spreadsheet. envision userform having 2 bottons (which hidden , appear conditions of subroutine). working on mac, way, , know have vba coding implications use on pc och vice versa.
the example sheet this:
the example userform (a) this:
for argument's sake, let want update or input number of tasks greg completed on 7th of may (2013/05/07).
i userform proceed this:
entering person , date:
then, retrieving number of tasks greg on 7th after button click:
now, want input know greg completed 6 tasks on 7th , click second button (now visible , first button hidden):
and result in spreadsheet:
i ought input code here, skills , completeness of code wanting. put in have:
option explicit 'subroutine when clicking first ("find") button private sub btnfind_click() lbltasks.vissible = true txttasks.visible = true btnupdate.visible = true btnfind.visible = false 'defining variables dim pr01 string dim dt01 date dim tsk01 integer 'assigning variables inputs pr01 = txtperson.text dt01 = txtdate.text tsk01 = txttask.text 'looking name in column "a" ' ? ? ? 'looking inut date in row "1" ' ? ? ? 'retrieving existing number of tasks according name , date 'and showing number in 'tasks' text input box in user form ' ? ? ? end sub 'subroutine when clicking second ("update") button private sub btnupdate_click() 'paste updated number of tasks in appropriate cells according name , date 'the new number of tasks should on write there ' ? ? ? end sub
thanks in advance , help!
this should work. please study , use macro record function in excel grasp lot more:
option explicit public frmname variant 'store row of name public frmdate variant 'store column of date 'subroutine when clicking first ("find") button private sub btnfind_click() 'defining variables dim pr01 string dim dt01 date dim tsk01 integer 'assigning variables inputs pr01 = userform1.textbox1.text dt01 = userform1.textbox2.text tsk01 = userform1.textbox3.text 'looking name in column "a" thisworkbook.worksheets("sheet4") frmname = .columns("a").find(pr01).row end 'looking inut date in row "1" thisworkbook.worksheets("sheet4") frmdate = .rows(1).find(cdate(dt01)).column end if frmname nothing or frmdate nothing 'not found exit sub end if 'retrieving existing number of tasks according name , date 'and showing number in 'tasks' text input box in user form thisworkbook.worksheets("sheet4") userform1.textbox3.text = .cells(frmname, frmdate) end end sub 'subroutine when clicking second ("update") button private sub btnupdate_click() 'paste updated number of tasks in appropriate cells according name , date 'the new number of tasks should on write there thisworkbook.worksheets("sheet4") .cells(frmname, frmdate) = userform1.textbox3.text end end sub
Comments
Post a Comment