• Bad VBA code (Excel xp)

    Author
    Topic
    #409091

    Very long code fragment moved to attachment – HansV

    I have this code that i want to make more efficient. I don’t know how to cycle through letters A through N. Please let me know how i can fix this code. Thanks

    Viewing 1 reply thread
    Author
    Replies
    • #869243

      Here is a minimal adjustment:

      Dim c As Integer
      For c = Asc(“A”) To Asc(“N”)
      Set rngB = Workbooks(xlsFile).Sheets(numSheet).Range(Chr© & n1 & “,” & Chr© & n2 & “,” & Chr© & n3 & “,” & Chr© & n4)
      i = 0
      For Each r In rngB
      ‘r.Select
      r.Copy
      shtSource.Range(rngS).Offset(0, i).PasteSpecial (xlPasteValues)
      i = i + 1
      Next r
      Next c

    • #869244

      Here is a minimal adjustment:

      Dim c As Integer
      For c = Asc(“A”) To Asc(“N”)
      Set rngB = Workbooks(xlsFile).Sheets(numSheet).Range(Chr© & n1 & “,” & Chr© & n2 & “,” & Chr© & n3 & “,” & Chr© & n4)
      i = 0
      For Each r In rngB
      ‘r.Select
      r.Copy
      shtSource.Range(rngS).Offset(0, i).PasteSpecial (xlPasteValues)
      i = i + 1
      Next r
      Next c

    Viewing 1 reply thread
    Reply To: Bad VBA code (Excel xp)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: