Gday all,
I've been trying my hand at writing a macro to compile data from two separate sheets, I've gotten a lot of more simple stuff to work but the macro i've created to copy selective rows of data into a new sheet seems to do nothing.
I figure i've probably got some usage/ syntax way off, any errors you can see/ ways to simplify or improve the code would be greatly appreciated.
The premise is that i have an entire month of time usage data for our equipment, night and day shifts, and i also have production data for the month, but the production data is only present for those days/shifts that were active, so its not possible to just line up a copy and paste.
Columns A is the equipment's name
Column B is the date
Column C is the shift
Column D through F is the desired data to be copied.
The code in question is:
Dim prodrow
Dim exportrow
prodrow = 2
exportrow = 3
Do While prodrow < 162
Do While exportrow < 473
Sheets("Export").Select
If Range("A" & exportrow) = Sheets("prod").Range("A" & prodrow) Then
MsgBox "Column A Matches"
If Range("B" & exportrow) = Sheets("prod").Range("B" & prodrow) Then
MsgBox "Column B Matches"
If Range("C" & exportrow) = Sheets("prod").Range("C" & prodrow) Then
MsgBox "Column C Matches"
Sheets("prod").Select
Range("D" & prodrow : "F" & prodrow).Select
Selection.Copy
Sheets("EXPORT").Select
Range("D" & exportrow).Select
ActiveSheet.Paste
prodrow = prodrow + 1
exportrow = 3
Else: exportrow = exportrow + 1
End If
Else: exportrow = exportrow + 1
End If
Else: exportrow = exportrow + 1
End If
Exit Do
Loop
Exit Do
Loop
Once again, any help would be greatly appreciated.
Cheers,
I've been trying my hand at writing a macro to compile data from two separate sheets, I've gotten a lot of more simple stuff to work but the macro i've created to copy selective rows of data into a new sheet seems to do nothing.
I figure i've probably got some usage/ syntax way off, any errors you can see/ ways to simplify or improve the code would be greatly appreciated.
The premise is that i have an entire month of time usage data for our equipment, night and day shifts, and i also have production data for the month, but the production data is only present for those days/shifts that were active, so its not possible to just line up a copy and paste.
Columns A is the equipment's name
Column B is the date
Column C is the shift
Column D through F is the desired data to be copied.
The code in question is:
Dim prodrow
Dim exportrow
prodrow = 2
exportrow = 3
Do While prodrow < 162
Do While exportrow < 473
Sheets("Export").Select
If Range("A" & exportrow) = Sheets("prod").Range("A" & prodrow) Then
MsgBox "Column A Matches"
If Range("B" & exportrow) = Sheets("prod").Range("B" & prodrow) Then
MsgBox "Column B Matches"
If Range("C" & exportrow) = Sheets("prod").Range("C" & prodrow) Then
MsgBox "Column C Matches"
Sheets("prod").Select
Range("D" & prodrow : "F" & prodrow).Select
Selection.Copy
Sheets("EXPORT").Select
Range("D" & exportrow).Select
ActiveSheet.Paste
prodrow = prodrow + 1
exportrow = 3
Else: exportrow = exportrow + 1
End If
Else: exportrow = exportrow + 1
End If
Else: exportrow = exportrow + 1
End If
Exit Do
Loop
Exit Do
Loop
Once again, any help would be greatly appreciated.
Cheers,