Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output

Status
Not open for further replies.

wafs

Technical User
Jan 17, 2006
112
US
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


 
Code:
For z = 1 To lastrow

whats the value of lastrow ?

Chance,

Filmmaker, taken gentleman and He tan e epi tas
 
Can you explain in English what you are aiming for the processing to be. It's going to be a lot easier than absorbing your code and then trying to work out what you meant it to do ( as opposed to what it's actually doing ).

Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
What I'm trying to do is create a macro that will look for column AF to be over thrity and move the part number in column A over to a seperate sheet. Right now, it moves all part numbers to a seperate sheet, not just the ones that are over 30.

The value of lastrow is Range("AF:5000"). So last row to look at is row 5000.

Let me know if I can do any more clearifing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top