copy between arrays - subscript out of range
Need to copy elements between arrays before I paste it into my worksheet.
But when I run this subrutine I get an "Subscript out of range"-error in the line with "faktura_kopi(r, c) = faktura_tabell(r, c)"
Please help!
Sub Hent_faktura()
'
' Hent_faktura Makro
'
'
Dim faktura_tabell As Variant
Dim rader As Integer
Dim kolonner As Integer
Dim tabell_ref As String
Dim fakturanr As Integer
Dim r, c As Integer
Dim faktura_kopi() As Variant
Sheets("Fakturaarkiv").Select
fakturanr = Worksheets("Endre faktura").Range("B1").Value
Range("B6").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
omr = Selection.Address
faktura_tabell = Range(omr)
rader = UBound(faktura_tabell, 1)
kolonner = UBound(faktura_tabell, 2)
'Copy between arrays keeping only rows with fakturanr in (r,7)
For r = 1 To rader
If faktura_tabell(r, 7) = fakturanr Then
For c = 1 To kolonner
faktura_kopi(r, c) = faktura_tabell(r, c)
Next c
End If
Next r
Sheets("Endre faktura").Select
Range("a4").Select
omr = "A4:I" & 4 + UBound(faktura_kopi)
Range(omr) = faktura_kopi
End Sub
Last edited by Tore Berg; October 14th, 2014 at 07:26 AM..
|