[TABLE="width: 144"]
<colgroup><col style="width: 48pt;" span="3" width="64"> <tbody>[TR]
[TD="width: 128, bgcolor: transparent, colspan: 2"]Hi
I am gettin a run time error when trying to use the below macro in VBA. It opens the file but then doesnt do anything else and returns me the error message.
Sub Macro3()[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim qfile(), i As Integer[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim thiswb As Workbook, datawb As Workbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim qrow As Integer[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Set thiswb = ActiveWorkbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Sheets("Sheet1").Range("A2").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]qfile = Array("G:\Finance, Performance & Business Planning\Management Accounts\2015 Budget\Working templates\1st Issue\Business Development.*", _[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] "G:\Finance, Performance & Business Planning\2012_Business Planning\3 yr Budget & planning\2013 budgets and plans\Budgets Received\Customer engagement.*")[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] For i = O To UBound(qfile)[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Workbooks.Open Filename:=qfile(i), ReadOnly:=True[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Set datawb = ActiveWorkbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Sheets("Sheet1").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] qrow = Cells(Rows.Count, 1).End(xlUp).Row[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Range("A7").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Do Until ActiveCell.Row = qrow[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] If ActiveCell.Value <> "" Then[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.EntireRow.Copy[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] thiswb.Activate[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.PasteSpecial xlPasteValues[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] datawb.Activate[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 2"] Else[/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 2"] End If[/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"] Loop[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] datawb.Close SaveChanges:=False[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Next i[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]End Sub[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
<colgroup><col style="width: 48pt;" span="3" width="64"> <tbody>[TR]
[TD="width: 128, bgcolor: transparent, colspan: 2"]Hi
I am gettin a run time error when trying to use the below macro in VBA. It opens the file but then doesnt do anything else and returns me the error message.
Sub Macro3()[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim qfile(), i As Integer[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim thiswb As Workbook, datawb As Workbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Dim qrow As Integer[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Set thiswb = ActiveWorkbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]Sheets("Sheet1").Range("A2").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]qfile = Array("G:\Finance, Performance & Business Planning\Management Accounts\2015 Budget\Working templates\1st Issue\Business Development.*", _[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] "G:\Finance, Performance & Business Planning\2012_Business Planning\3 yr Budget & planning\2013 budgets and plans\Budgets Received\Customer engagement.*")[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] For i = O To UBound(qfile)[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Workbooks.Open Filename:=qfile(i), ReadOnly:=True[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Set datawb = ActiveWorkbook[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Sheets("Sheet1").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] qrow = Cells(Rows.Count, 1).End(xlUp).Row[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Range("A7").Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] Do Until ActiveCell.Row = qrow[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] If ActiveCell.Value <> "" Then[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.EntireRow.Copy[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] thiswb.Activate[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.PasteSpecial xlPasteValues[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] datawb.Activate[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 2"] Else[/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] ActiveCell.Offset(1, 0).Select[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 2"] End If[/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"] Loop[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"] datawb.Close SaveChanges:=False[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]Next i[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]End Sub[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]