Hi EXPERTS ,

I want to achieve something basic. Copy and pasting a sheet of data from one sheet into another sheet and renaming the new pasted info with the sheet name "starting point". The trouble is - it's very slow for something so straitforward. I know you experts - better coding. Can some help me code this better to make it faster.


VB Code:
  1. Sub ProduceStartingPoint()
  2.  
  3. Dim arraydata() As String
  4. Dim i As Long
  5. Dim j As Long
  6. Dim x As Long
  7. Dim y As Long
  8. Dim z As Long
  9. Dim FileLength As Long
  10. Dim RowCount As Long
  11. Dim sheetcount As Integer
  12.  
  13. 'Count Worksheets
  14. sheetcount = Worksheets.Count
  15.  
  16. 'Add worksheets after the last sheet
  17. Worksheets.Add after:=Sheets(sheetcount)
  18.  
  19. 'Count Worksheets
  20. sheetcount = Worksheets.Count
  21.  
  22. 'Name the sheet and add the number of sheets
  23. Worksheets(sheetcount).Name = "Starting point"
  24.  
  25. 'Activate worksheet
  26. Worksheets(1).Activate
  27.  
  28. 'Find FileLength
  29. Range("A:A").Select
  30. FileLength = Selection.Cells.Count
  31.  
  32. 'Find RowCount
  33. Range("1:1").Select
  34. RowCount = Selection.Cells.Count
  35.  
  36. 'Create ActiveCell
  37. Range("A2").Activate
  38.  
  39. 'set x to first column
  40. x = 1
  41.  
  42. 'set y to second row
  43. y = 1
  44.  
  45. 'Finds number of rows and columns
  46.  
  47. For j = 1 To RowCount
  48.     If ActiveCell.Offset(0, 1) <> "" Then
  49.     x = x + 1
  50.     ActiveCell.Offset(0, 1).Activate
  51.     Else
  52.     GoTo nextrow
  53.     End If
  54. Next j
  55.  
  56. nextrow:
  57.  
  58. For i = 1 To FileLength
  59.   y = y + 1
  60.   Range("A" & y).Select
  61.   If ActiveCell.Offset(1, 0) = "" Then
  62.   GoTo InputArrayData
  63.   End If
  64. Next i
  65.  
  66. InputArrayData:
  67.  
  68. 'ReDimension the array
  69. ReDim arraydata(y, x) As String
  70.  
  71. For i = 1 To y
  72. Worksheets(2).Activate
  73. Range("A" & i).Select
  74. Worksheets(1).Activate
  75. Range("A" & i).Select
  76.   For j = 1 To x
  77.   Worksheets(1).Activate
  78.   arraydata(y, x) = ActiveCell.Text
  79.   ActiveCell.Offset(0, 1).Activate
  80.   Worksheets(2).Activate
  81.   ActiveCell.formula = arraydata(y, x)
  82.   ActiveCell.Offset(0, 1).Activate
  83.   Next j
  84. Next i
  85.  
  86. End Sub

Cheers,

Borris.