Dear friends,
I have 2 workbooks.
1st contains the data and the 2nd contains specific cells from 1st workbook.
Code is runing under a button in the 1st book.
It's working for each raw manually, if i don't use the loop.
Using the loop it doesn't copy anything.
Any ideas?
Sub UpdateActionPlan()
Dim intAdded As Integer, intSRow, intTRow
Dim sngRecord(6)
Dim strTFullPath As String
Dim cancel As Integer
Dim strFileName As String
Dim i As Integer
Dim LastRow As Integer
Dim FirstRow As Integer
FirstRow = 7
LastRow = 1000
i = FirstRow
strFileName = “Test.xls”
strTFullPath = strFileName
Workbooks.Open filename:=strTFullPath
Do Until i > LastRow
If Range("S" & i).Value = "Action" Then
sngRecord(0) = Range("C" & i).Value
sngRecord(1) = Range("G" & i).Value
sngRecord(2) = Range("N" & i).Value
sngRecord(3) = Range("O" & i).Value
sngRecord(4) = Range("P" & i).Value
sngRecord(5) = Range("T6").Value
With Workbooks("Test.xlsx").Worksheets("CheckSheet")
intTRow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Range("C" & intTRow) = sngRecord(0)
.Range("E" & intTRow) = sngRecord(1)
.Range("G" & intTRow) = sngRecord(2)
.Range("A" & intTRow) = sngRecord(3)
.Range("D" & intTRow) = sngRecord(4)
.Range("B" & intTRow) = sngRecord(5)
End With
Else
Cancel = True
End If
i = i + 1
Loop
End Sub
I have 2 workbooks.
1st contains the data and the 2nd contains specific cells from 1st workbook.
Code is runing under a button in the 1st book.
It's working for each raw manually, if i don't use the loop.
Using the loop it doesn't copy anything.
Any ideas?
Sub UpdateActionPlan()
Dim intAdded As Integer, intSRow, intTRow
Dim sngRecord(6)
Dim strTFullPath As String
Dim cancel As Integer
Dim strFileName As String
Dim i As Integer
Dim LastRow As Integer
Dim FirstRow As Integer
FirstRow = 7
LastRow = 1000
i = FirstRow
strFileName = “Test.xls”
strTFullPath = strFileName
Workbooks.Open filename:=strTFullPath
Do Until i > LastRow
If Range("S" & i).Value = "Action" Then
sngRecord(0) = Range("C" & i).Value
sngRecord(1) = Range("G" & i).Value
sngRecord(2) = Range("N" & i).Value
sngRecord(3) = Range("O" & i).Value
sngRecord(4) = Range("P" & i).Value
sngRecord(5) = Range("T6").Value
With Workbooks("Test.xlsx").Worksheets("CheckSheet")
intTRow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Range("C" & intTRow) = sngRecord(0)
.Range("E" & intTRow) = sngRecord(1)
.Range("G" & intTRow) = sngRecord(2)
.Range("A" & intTRow) = sngRecord(3)
.Range("D" & intTRow) = sngRecord(4)
.Range("B" & intTRow) = sngRecord(5)
End With
Else
Cancel = True
End If
i = i + 1
Loop
End Sub