Saturday, 15 June 2013

excel - Update userform with values in range -



excel - Update userform with values in range -

i have sheet tracks when people in building notified of bundle arrivals, , info package. have "send reminders" button shows userform, meant through sheet , determine packages have been waiting more 2 days, , fill in several fields on form appropriate info user (i not have reputation yet, cannot post image).

the first text box email, sec subject, , 3rd message. there next button causes form initialize again, hoping next bundle has been waiting, , if there none found, form closes.

the problem when click button show form, email box , message box both show blank, although subject box fine.

private sub userform_initialize() dim checkrange range dim rcell range dim k integer on error resume next k = 0 sheets(1).activate checkrange = activesheet.range("d3", "d100") each rcell in checkrange.cells if rcell.value >= 2 email.value = cells(rcell.row, 1).value subject.value = "package reminder" message.value = "this reminder have bundle " & _ cells(rcell.row, 2).value & _ " waiting in machine shop." k = 1 cells(rcell.row, 3).value = date exit end if next rcell if k = 0 unload me msgbox ("all reminders sent!") end if end sub

edit:

i must blind; didn't realize line of code doing!

checkrange = activesheet.range("d3", "d100")

this should be:

checkrange = activesheet.range("d3:d100")

hope helps; sorry slow! :)

original:

i tried writing code described see how functioned.

this came with; hope helps in way!

i'm not sure wrong code because pretty much same thing , works expected:

private sub userform_initialize() dim rcell dim foundpackage foundpackage = false each rcell in sheets("sheet1").range("d2:d12") if rcell.value >= 2 , sheets("sheet1").cells(rcell.row, 3).value = "" 'added , goes next 1 after date set email.value = sheets("sheet1").cells(rcell.row, 1).value subject.value = "package reminder" message.value = "this reminder have bundle " & _ sheets("sheet1").cells(rcell.row, 2).value & " waiting in machine shop." sheets("sheet1").cells(rcell.row, 3).value = date 'this set date on cell - believe intended foundpackage = true exit end if next rcell if foundpackage = false unload me msgbox ("all reminders sent!") end if end sub

excel vba userform

No comments:

Post a Comment