مشکل در حلقه تکرار

Collapse
این تاپیک قفل است.
X
X
 
  • زمان
  • نمایش
حذف همه
new posts
  • perspolis52

    • 2015/03/01
    • 27

    [حل شده] مشکل در حلقه تکرار

    سلام دوستان
    Private Sub save_Click()
    On Error Resume Next

    Range("a1").Select
    endrow = info.Range("a:a").Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
    Dim c As Range
    For Each c In Range("a1:a" & endrow)
    If ActiveCell.Value <> "" Then
    ActiveCell.Offset(1, 0).Select
    End If
    Next
    Selection = name_code.Text
    ActiveCell.Offset(0, 3).Value = num.Text
    ActiveCell.Offset(0, 2).Value = month.Text
    End Sub


    این کد رو اگه بخوام به تعداد اعداد موجود در num.Text تکرار کنم باید چه کار کنم. مثلا اگه توی num.Text عدد 5 هست این عملیات 5 بار تکرار بشه.
    ممنون میشم اگه جواب بدین
  • iranweld

    • 2015/03/29
    • 3341

    #2
    نمونه فایل را بصورت زیپ شده ضمیمه سایت کنید

    کامنت

    • perspolis52

      • 2015/03/01
      • 27

      #3
      نوشته اصلی توسط iranweld
      نمونه فایل را بصورت زیپ شده ضمیمه سایت کنید
      بیا دادا اینم فایل
      فایل های پیوست شده

      کامنت

      • Ali Parsaei
        مدير تالارتوابع اکسل

        • 2013/11/18
        • 1522
        • 71.67

        #4
        سلام،
        بيا دادا اينم کد:

        کد PHP:
        Private Sub save_Click()
        Dim D As Integer
        num.Value
        Do While 0
        On Error Resume Next
        morakhasi
        .Activate
        Range
        ("a1").Selectendrow sheet1.Range("a:a").Cells.Find("*"searchorder:=xlByRowssearchdirection:=xlPrevious).Row
        Dim c 
        As Range
        For Each c In Range("a1:a" endrow)
        If 
        ActiveCell.Value <> "" Then
        ActiveCell
        .Offset(10).SelectEnd IfNextSelection name_code.Text
        ActiveCell
        .Offset(03).Value num.Text
        ActiveCell
        .Offset(02).Value month.Text
        1
        Loop
        name_code
        .Text ""
        num.Text ""
        month.Text ""
        End Sub 
        Last edited by Ali Parsaei; 2017/08/08, 16:51.
        [SIGPIC][/SIGPIC]

        کامنت

        • perspolis52

          • 2015/03/01
          • 27

          #5
          نوشته اصلی توسط علي پارسا
          سلام،
          بيا دادا اينم کد:

          کد PHP:
          Private Sub save_Click()
          Dim D As Integer
          num.Value
          Do While 0
          On Error Resume Next
          morakhasi
          .Activate
          Range
          ("a1").Selectendrow sheet1.Range("a:a").Cells.Find("*"searchorder:=xlByRowssearchdirection:=xlPrevious).Row
          Dim c 
          As Range
          For Each c In Range("a1:a" endrow)
          If 
          ActiveCell.Value <> "" Then
          ActiveCell
          .Offset(10).SelectEnd IfNextSelection name_code.Text
          ActiveCell
          .Offset(03).Value num.Text
          ActiveCell
          .Offset(02).Value month.Text
          1
          Loop
          name_code
          .Text ""
          num.Text ""
          month.Text ""
          End Sub 


          خیلی ممنون و لی خطای "Loop Without Do" میده؟؟

          کامنت

          • Ali Parsaei
            مدير تالارتوابع اکسل

            • 2013/11/18
            • 1522
            • 71.67

            #6
            ببخشيد، موقع درج کد در سايت يک کم به هم ريختگي ايجاد شد، اين فايل را ببينيد:

            کد PHP:
            Private Sub save_Click()
            Dim D As Integer
            num.Value
            On Error Resume Next
            morakhasi
            .Activate
            Range
            ("a1").Select
            endrow 
            sheet1.Range("a:a").Cells.Find("*"searchorder:=xlByRowssearchdirection:=xlPrevious).Row
            Dim c 
            As Range
            For Each c In Range("a1:a" endrow)
            If 
            ActiveCell.Value <> "" Then
            ActiveCell
            .Offset(10).Select
            End 
            If
            Next
            Do While 0
            Selection 
            name_code.Text
            ActiveCell
            .Offset(03).Value num.Text
            ActiveCell
            .Offset(02).Value month.Text
            Selection
            .Offset(10).Select
            1
            Loop
            name_code
            .Text ""
            num.Text ""
            month.Text ""
            End Sub 
            فایل های پیوست شده
            Last edited by Ali Parsaei; 2017/08/09, 11:51.
            [SIGPIC][/SIGPIC]

            کامنت

            چند لحظه..