Results 1 to 15 of 15

Data Copied Excess in columns

Threaded View

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    76

    Thumbs down Data Copied Excess in columns

    Dear experts

    I am newbie here, i have a excel workbook contains two sheets & i have code
    i cant explain hence please see attached workbook.
    if my "Material in" sheet data has upto 3 coulmns, then remain data should be copied upto 3 rows , but it copied upto 40 rows

      Dim rng As Range
      Dim temp As Variant
      Dim i As Long
      Dim a As Long
      Dim rng_dest As Range
      i = 1
      Set rng_dest = Sheets("Material In").Range("A:C")
      'Find first empty row in columns D:J on sheet Invoice data
      Do Until WorksheetFunction.CountA(rng_dest.Rows(i)) = 0
        i = i + 1
      Loop
      'Copy range B16:I34 on sheet Invoice to Variant array
      Set rng = Sheets("Voucher Material Inward").Range("D7:F50")
      For a = 1 To rng.Rows.Count
        If WorksheetFunction.CountA(rng.Rows(a)) <> 0 Then
          rng_dest.Rows(i).Value = rng.Rows(a).Value
          'Copy Invoice number
          Sheets("Material In").Range("F" & i).Value = Sheets("Voucher Material Inward").Range("C5").Value
          'Copy invoice Date
          Sheets("Material In").Range("G" & i).Value = Sheets("Voucher Material Inward").Range("E5").Value
          'Copy Company name
          Sheets("Material In").Range("E" & i).Value = Sheets("Voucher Material Inward").Range("C4").Value
          'Receipt Date
          Sheets("Material In").Range("D" & i).Value = Sheets("Voucher Material Inward").Range("C3").Value
          'Site Name
          Sheets("Material In").Range("H" & i).Value = Sheets("Voucher Material Inward").Range("E3").Value
          i = i + 1
        End If
      Next a
    End Sub
    Please help me Thanks in advance

    Your help would be highly appreciated.

    Thanks
    Sagar007
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1