excel vba - Runtime error 9: Subscript out of range -
i'm doing employee leave database , i'm getting this:
runtime error 9: subscript out of range.
this how code looks like. , error occurs in designated part.
private sub cmdadd_click() dim rowcount long dim vlabsenceutwpay, vlabsenceutwoutpay, vlbalance single dim slabsenceutwpay, slabsenceutwoutpay, slbalance single if me.reg1.value = "" msgbox "please enter entry no.", vbexclamation, "employee data" me.reg1.setfocus end if '-----vacation leave------ vlabsenceutwpay = reg9.value * 0.00208333333 vlabsenceutwoutpay = reg10.value * 0.00208333333 vlbalance = (reg11.value + reg8.value) - (vlabsenceutwpay + vlabsenceutwoutpay) '-----sick leave------------ slabsenceutwpay = reg12.value * 0.00208333333 slabsenceutwoutpay = reg13.value * 0.00208333333 slbalance = (reg14.value + reg8.value) - (slabsenceutwpay + slabsenceutwoutpay) rowcount = worksheets("sheet1").range("b8").currentregion.rows.count ' <<< error line worksheets("sheet1").range("b8") .offset(rowcount, 0) = me.reg1.value .offset(rowcount, 1) = me.reg2.value .offset(rowcount, 2) = me.reg3.value .offset(rowcount, 3) = me.reg4.value .offset(rowcount, 4) = me.reg5.value .offset(rowcount, 5) = me.reg6.value .offset(rowcount, 6) = me.reg7.value .offset(rowcount, 7) = me.reg8.value .offset(rowcount, 8) = me.reg9.value .offset(rowcount, 9) = vlabsenceutwpay .offset(rowcount, 10) = me.reg10.value .offset(rowcount, 11) = vlabsenceutwoutpay .offset(rowcount, 12) = me.reg11.value .offset(rowcount, 13) = vlbalance .offset(rowcount, 14) = me.reg12.value .offset(rowcount, 15) = slabsenceutwpay .offset(rowcount, 16) = me.reg13.value .offset(rowcount, 17) = slabsenceutwoutpay .offset(rowcount, 18) = me.reg14.value .offset(rowcount, 19) = slbalance .offset(rowcount, 20) = me.reg15.value end end sub
Comments
Post a Comment