اذهب الي المحتوي
أوفيسنا
حماده ممدوح البحيرى

تبسيط كود بـــ for next

Recommended Posts

السلام عليكم 

اخوانى احتاج الى تبسيط كود الترحيل هذا حيث اننى لم استطع ذلك 

وشكرا لكم..

ثم

ازاى ارفع ملف اكسل على المنتدى لانى لم استطع ذلك 

Private Sub CommandButton3_Click()

Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("sheet2")
iRow = ws.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row

ws.Cells(iRow, 1).Value = Me.costum.Value
ws.Cells(iRow, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow, 4).Value = Me.c1.Value
ws.Cells(iRow, 5).Value = Me.c11.Value
ws.Cells(iRow, 6).Value = Me.t1.Value
ws.Cells(iRow, 7).Value = Me.t11.Value
ws.Cells(iRow, 8).Value = Me.t111.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value

ws.Cells(iRow + 1, 1).Value = Me.costum.Value
ws.Cells(iRow + 1, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 1, 4).Value = Me.c2.Value
ws.Cells(iRow + 1, 5).Value = Me.c22.Value
ws.Cells(iRow + 1, 6).Value = Me.T2.Value
ws.Cells(iRow + 1, 7).Value = Me.T22.Value
ws.Cells(iRow + 1, 8).Value = Me.T222.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 2, 1).Value = Me.costum.Value
ws.Cells(iRow + 2, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 2, 4).Value = Me.C3.Value
ws.Cells(iRow + 2, 5).Value = Me.c33.Value
ws.Cells(iRow + 2, 6).Value = Me.t3.Value
ws.Cells(iRow + 2, 7).Value = Me.t33.Value
ws.Cells(iRow + 2, 8).Value = Me.t333.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 3, 1).Value = Me.costum.Value
ws.Cells(iRow + 3, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 3, 4).Value = Me.c4.Value
ws.Cells(iRow + 3, 5).Value = Me.c44.Value
ws.Cells(iRow + 3, 6).Value = Me.t4.Value
ws.Cells(iRow + 3, 7).Value = Me.t44.Value
ws.Cells(iRow + 3, 8).Value = Me.t444.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 4, 1).Value = Me.costum.Value
ws.Cells(iRow + 4, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 4, 4).Value = Me.c5.Value
ws.Cells(iRow + 4, 5).Value = Me.c55.Value
ws.Cells(iRow + 4, 6).Value = Me.t5.Value
ws.Cells(iRow + 4, 7).Value = Me.t55.Value
ws.Cells(iRow + 4, 8).Value = Me.t555.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 5, 1).Value = Me.costum.Value
ws.Cells(iRow + 5, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 5, 4).Value = Me.c6.Value
ws.Cells(iRow + 5, 5).Value = Me.c66.Value
ws.Cells(iRow + 5, 6).Value = Me.t6.Value
ws.Cells(iRow + 5, 7).Value = Me.t66.Value
ws.Cells(iRow + 5, 8).Value = Me.t666.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 6, 1).Value = Me.costum.Value
ws.Cells(iRow + 6, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 6, 4).Value = Me.c7.Value
ws.Cells(iRow + 6, 5).Value = Me.c77.Value
ws.Cells(iRow + 6, 6).Value = Me.t7.Value
ws.Cells(iRow + 6, 7).Value = Me.t77.Value
ws.Cells(iRow + 6, 8).Value = Me.t777.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 7, 1).Value = Me.costum.Value
ws.Cells(iRow + 7, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 7, 4).Value = Me.c8.Value
ws.Cells(iRow + 7, 5).Value = Me.c88.Value
ws.Cells(iRow + 7, 6).Value = Me.t8.Value
ws.Cells(iRow + 7, 7).Value = Me.t88.Value
ws.Cells(iRow + 7, 8).Value = Me.t888.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 8, 1).Value = Me.costum.Value
ws.Cells(iRow + 8, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 8, 4).Value = Me.c9.Value
ws.Cells(iRow + 8, 5).Value = Me.c99.Value
ws.Cells(iRow + 8, 6).Value = Me.t9.Value
ws.Cells(iRow + 8, 7).Value = Me.t99.Value
ws.Cells(iRow + 8, 8).Value = Me.t999.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 9, 1).Value = Me.costum.Value
ws.Cells(iRow + 9, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 9, 4).Value = Me.ca.Value
ws.Cells(iRow + 9, 5).Value = Me.caa.Value
ws.Cells(iRow + 9, 6).Value = Me.ta.Value
ws.Cells(iRow + 9, 7).Value = Me.taa.Value
ws.Cells(iRow + 9, 8).Value = Me.taaa.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 10, 1).Value = Me.costum.Value
ws.Cells(iRow + 10, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 10, 4).Value = Me.cb.Value
ws.Cells(iRow + 10, 5).Value = Me.cbb.Value
ws.Cells(iRow + 10, 6).Value = Me.tb.Value
ws.Cells(iRow + 10, 7).Value = Me.tbb.Value
ws.Cells(iRow + 10, 8).Value = Me.tbbb.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 11, 1).Value = Me.costum.Value
ws.Cells(iRow + 11, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 11, 4).Value = Me.cc.Value
ws.Cells(iRow + 11, 5).Value = Me.ccc.Value
ws.Cells(iRow + 11, 6).Value = Me.tc.Value
ws.Cells(iRow + 11, 7).Value = Me.tcc.Value
ws.Cells(iRow + 11, 8).Value = Me.tccc.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 12, 1).Value = Me.costum.Value
ws.Cells(iRow + 12, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 12, 4).Value = Me.cd.Value
ws.Cells(iRow + 12, 5).Value = Me.cdd.Value
ws.Cells(iRow + 12, 6).Value = Me.td.Value
ws.Cells(iRow + 12, 7).Value = Me.tdd.Value
ws.Cells(iRow + 12, 8).Value = Me.tddd.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 13, 1).Value = Me.costum.Value
ws.Cells(iRow + 13, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 13, 4).Value = Me.ce.Value
ws.Cells(iRow + 13, 5).Value = Me.cee.Value
ws.Cells(iRow + 13, 6).Value = Me.te.Value
ws.Cells(iRow + 13, 7).Value = Me.tee.Value
ws.Cells(iRow + 13, 8).Value = Me.teee.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 14, 1).Value = Me.costum.Value
ws.Cells(iRow + 14, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 14, 4).Value = Me.cf.Value
ws.Cells(iRow + 14, 5).Value = Me.cff.Value
ws.Cells(iRow + 14, 6).Value = Me.tf.Value
ws.Cells(iRow + 14, 7).Value = Me.tff.Value
ws.Cells(iRow + 14, 8).Value = Me.tfff.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 15, 1).Value = Me.costum.Value
ws.Cells(iRow + 15, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 15, 4).Value = Me.cg.Value
ws.Cells(iRow + 15, 5).Value = Me.cgg.Value
ws.Cells(iRow + 15, 6).Value = Me.tg.Value
ws.Cells(iRow + 15, 7).Value = Me.tgg.Value
ws.Cells(iRow + 15, 8).Value = Me.tggg.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 16, 1).Value = Me.costum.Value
ws.Cells(iRow + 16, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 16, 4).Value = Me.ch.Value
ws.Cells(iRow + 16, 5).Value = Me.chh.Value
ws.Cells(iRow + 16, 6).Value = Me.th.Value
ws.Cells(iRow + 16, 7).Value = Me.thh.Value
ws.Cells(iRow + 16, 8).Value = Me.thhh.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 17, 1).Value = Me.costum.Value
ws.Cells(iRow + 17, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 17, 4).Value = Me.ci.Value
ws.Cells(iRow + 17, 5).Value = Me.cii.Value
ws.Cells(iRow + 17, 6).Value = Me.ti.Value
ws.Cells(iRow + 17, 7).Value = Me.tii.Value
ws.Cells(iRow + 17, 8).Value = Me.tiii.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 18, 1).Value = Me.costum.Value
ws.Cells(iRow + 18, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value
ws.Cells(iRow + 18, 4).Value = Me.cj.Value
ws.Cells(iRow + 18, 5).Value = Me.cjj.Value
ws.Cells(iRow + 18, 6).Value = Me.tj.Value
ws.Cells(iRow + 18, 7).Value = Me.tjj.Value
ws.Cells(iRow + 18, 8).Value = Me.tjjj.Value
ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 19, 1).Value = Me.costum.Value
ws.Cells(iRow + 19, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 19, 4).Value = Me.ck.Value
ws.Cells(iRow + 19, 5).Value = Me.ckk.Value
ws.Cells(iRow + 19, 6).Value = Me.tk.Value
ws.Cells(iRow + 19, 7).Value = Me.tkk.Value
ws.Cells(iRow + 19, 8).Value = Me.tkkk.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 20, 1).Value = Me.costum.Value
ws.Cells(iRow + 20, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 20, 4).Value = Me.cl.Value
ws.Cells(iRow + 20, 5).Value = Me.cll.Value
ws.Cells(iRow + 20, 6).Value = Me.tl.Value
ws.Cells(iRow + 20, 7).Value = Me.tll.Value
ws.Cells(iRow + 20, 8).Value = Me.tlll.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 21, 1).Value = Me.costum.Value
ws.Cells(iRow + 21, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 21, 4).Value = Me.cm.Value
ws.Cells(iRow + 21, 5).Value = Me.cmm.Value
ws.Cells(iRow + 21, 6).Value = Me.tm.Value
ws.Cells(iRow + 21, 7).Value = Me.tmm.Value
ws.Cells(iRow + 21, 8).Value = Me.tmmm.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 22, 1).Value = Me.costum.Value
ws.Cells(iRow + 22, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 22, 4).Value = Me.cn.Value
ws.Cells(iRow + 22, 5).Value = Me.cnn.Value
ws.Cells(iRow + 22, 6).Value = Me.tn.Value
ws.Cells(iRow + 22, 7).Value = Me.tnn.Value
ws.Cells(iRow + 22, 8).Value = Me.tnnn.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 23, 1).Value = Me.costum.Value
ws.Cells(iRow + 23, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 23, 4).Value = Me.cq.Value
ws.Cells(iRow + 23, 5).Value = Me.cqq.Value
ws.Cells(iRow + 23, 6).Value = Me.tq.Value
ws.Cells(iRow + 23, 7).Value = Me.tqq.Value
ws.Cells(iRow + 23, 8).Value = Me.tqqq.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value


ws.Cells(iRow + 24, 1).Value = Me.costum.Value
ws.Cells(iRow + 24, 2).Value = Me.daate.Value
ws.Cells(iRow, 3).Value = Me.offer.Value

ws.Cells(iRow + 24, 4).Value = Me.cs.Value
ws.Cells(iRow + 24, 5).Value = Me.css.Value
ws.Cells(iRow + 24, 6).Value = Me.ts.Value
ws.Cells(iRow + 24, 7).Value = Me.tss.Value
ws.Cells(iRow + 24, 8).Value = Me.tsss.Value

ws.Cells(iRow, 9).Value = Me.total1.Value
ws.Cells(iRow, 10).Value = Me.kh.Value
ws.Cells(iRow, 11).Value = Me.total2.Value
ws.Cells(iRow, 12).Value = Me.mins.Value
ws.Cells(iRow, 13).Value = Me.total3.Value
Me.c1.SetFocus
End Sub

 

 

 

 

 

نسخة_من_قاعة_مسايا.xlsm

شارك هذه المشاركه


رابط المشاركه
شارك

اتبع المراحل التالية لرفع ملف في المنتدى

في الصورة التالية انقر على اضافة موضوع جديد

image.png.a2b06c07740bc879dc3cdbb24a5aeb82.png

ثم ادخل عنوان الموضوع في مكانه

وانزل اسفل وشرح الموضوع

ثم اسحب الملف وافلته في مكانه اسفله

وانقر زر الاضافة في الاسفل ايضا

image.png.680338f6c20bc08bdbbae3c2d667c3a1.png

شارك هذه المشاركه


رابط المشاركه
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • المتواجدين الان   0 اعضاء متواجدين الان

    لايوجد اعضاء مسجلون يتصفحون هذه الصفحه

×
×
  • اضف...