so have vba code have reference cell. there possible way work down list of data each time macro loops? example, first loop need refer cell a1, second loop cell a2, , on
dim ie object dim strurl string dim objelement object sub login() ' add reference microsoft internet controls ' add reference microsoft html object library set ie = new shdocvw.internetexplorer ie.visible = true ie.navigate "https://minecraft.net/profile" while ie.busy doevents wend until not ie.busy , ie.readystate = 4 doevents loop ie.document.getelementbyid("username").value = "dynamic cell column a" ie.document.getelementbyid("password").value = "dynamic cell column b" dim htmlform htmlformelement set htmlform = ie.document.getelementbyid("loginform") htmlform.submit application.wait (now + #12:00:03 am#) ie.navigate "https://minecraft.net/profile/password" until not ie.busy , ie.readystate = 4 doevents loop ie.document.getelementbyid("oldpassword").value = "dynamic cell column b" ie.document.getelementbyid("password").value = "dynamic cell column c" ie.document.getelementbyid("passwordconfirmation").value = "dynamic cell column c" ie.document set elems = .getelementsbytagname("input") each e in elems if (e.getattribute("value") = "submit query") e.click exit end if next e set elems = .getelementsbytagname("a") each e in elems if (e.getattribute("value") = "log out") e.click exit end if next e end end sub
can use for...each loop:
sub loopeachcellinrange() dim myrange range dim mycell range set myrange = thisworkbook.worksheets("sheet1").range("a1:a20") each mycell in myrange mycell.offset(, 1) = mycell.address if isempty(mycell) mycell.offset(, 2) = "it's empty" if mycell.row > 1 mycell.offset(, 3) = mycell.row + mycell.offset(-1).row 'formula using r1c1 format. mycell.offset(, 4).formular1c1 = "=sum(r1c4:rc4)" 'formula using a1 format. mycell.offset(, 5).formula = "=sum(e1:" & mycell.offset(, 4).address & ")" end if next mycell end sub
Comments
Post a Comment