The following macro runs, but only reads one row in excel and outputs that number on every row in my dest. sheet. I know if is probably something simple that I'm overlooking, but I would appreciate a second pair of eyes to find what I'm missing and help me fix the problem.
Thanks,
Sub Over_30_Days()
Dim reportlocation As String
Dim destsh As String
Dim output(1 To 5) As String
Dim sh As String
Dim i As String
Dim lastrow As Integer
Dim z As Integer
Dim x As Integer
Dim TestRange As String
Dim TestRange2 As String
Dim TestRange3 As String
Dim parts As String
Dim m As String ' counting variable
Dim n As String 'counting variable
Dim v As String
Dim y As Integer
Dim cellstart As String
cellstart = 3
parts = 0
sh = "Daily"
destsh = "Over_30_Days"
'turn off screen updating
Application.ScreenUpdating = False
'Build over 30 sheet
lastrow = Range("A5000").End(xlUp).Row
For z = 1 To lastrow
'Get data from rows
i = cellstart
TestRange = "AF" + i
TestRange2 = "AE" + i
For x = cellstart To lastrow
If Sheets(sh).Range(TestRange) > 30 And Sheets(sh).Range(TestRange2) <> 0 Then
TestRange = "AF" + i
TestRange3 = TestRange
TestRange2 = "AE" + i
TestRange4 = TestRange2
Else
End If
n = cellstart
parts = parts + 1
'Part Number
output(1) = "A" + n
output(2) = Sheets(sh).Range(output(1)).Value
'Output
m = parts + 2
reportlocation = "A" + n
Sheets(destsh).Range(reportlocation) = output(2)
n = n + 1
TestRange3 = Selection.Address
i = i + 1
TestRange = "AF" + i
TestRange2 = "AE" + i
Next
cellstart = lastrow + 2
parts = parts + 1
Next
'Turn off screen updating
Application.ScreenUpdating = True
End Sub
Thanks,
Sub Over_30_Days()
Dim reportlocation As String
Dim destsh As String
Dim output(1 To 5) As String
Dim sh As String
Dim i As String
Dim lastrow As Integer
Dim z As Integer
Dim x As Integer
Dim TestRange As String
Dim TestRange2 As String
Dim TestRange3 As String
Dim parts As String
Dim m As String ' counting variable
Dim n As String 'counting variable
Dim v As String
Dim y As Integer
Dim cellstart As String
cellstart = 3
parts = 0
sh = "Daily"
destsh = "Over_30_Days"
'turn off screen updating
Application.ScreenUpdating = False
'Build over 30 sheet
lastrow = Range("A5000").End(xlUp).Row
For z = 1 To lastrow
'Get data from rows
i = cellstart
TestRange = "AF" + i
TestRange2 = "AE" + i
For x = cellstart To lastrow
If Sheets(sh).Range(TestRange) > 30 And Sheets(sh).Range(TestRange2) <> 0 Then
TestRange = "AF" + i
TestRange3 = TestRange
TestRange2 = "AE" + i
TestRange4 = TestRange2
Else
End If
n = cellstart
parts = parts + 1
'Part Number
output(1) = "A" + n
output(2) = Sheets(sh).Range(output(1)).Value
'Output
m = parts + 2
reportlocation = "A" + n
Sheets(destsh).Range(reportlocation) = output(2)
n = n + 1
TestRange3 = Selection.Address
i = i + 1
TestRange = "AF" + i
TestRange2 = "AE" + i
Next
cellstart = lastrow + 2
parts = parts + 1
Next
'Turn off screen updating
Application.ScreenUpdating = True
End Sub