I have built an function that (should) copy relevant cells from one worksheet to another worksheet. However the code does not function properly and if I move to the loop it only return blank cells. What goes wrong?
Hope you can help!
Hope you can help!
VBA Code:
Sub nieuw2()
Dim MyArray As Variant
Dim wb As Worksheet
Dim i As Long
Dim c As Long
Dim FoundCell As Range
Set wb = ThisWorkbook.Sheets("Import")
Cells.ClearOutline
ReDim MyArray(1 To i, 1 To c)
'
For c = 1 To wb.Columns.Count
c = c + 1
For i = 1 To wb.Rows.Count
' If wb.DataBodyRange(a, b).Value > 0 Then
'LookupValue = bron1.DataBodyRange(a, 2).Value
'Set FoundCell = bron2.DataBodyRange.Columns(4).Find(LookupValue, LookAt:=xlWhole)
' Rijnummer = FoundCell.Row - 1
i = i + 1
MyArray(i, 1) = wb.Cells(1, 3).Value
MyArray(i, 2) = wb.Cells(1, 4).Value
MyArray(i, 3) = wb.Cells(1, 7).Value
MyArray(i, 4) = wb.Cells(i, 10).Value
MyArray(i, 7) = "text"
MyArray(i, 10) = "text"
' End If
Next i
Next c
ThisWorkbook.Sheets("targetfile").Cells(1, 2) = MyArray
MsgBox "Export done."