fluxcapacitr609
New Member
- Joined
- Feb 21, 2018
- Messages
- 24
I have a workbook that has a csv string and dumps all my information on one page in 3 columns and i have a series of loops that searches through all the data and copies and pastes the information on another sheet. After that i have another loop that goes through the data copied and deletes the duplicates because everytime the excel sheet is open it runs the code and pastes the numbers again. I would like to create some loop that places the data in a coordinating slot. ex. would be if the date was the 3rd then it would paste the data in "I3" and if it was the 5th then "I5" and so on.
Code:
Sub extractDataHenlopenFebruary()
Dim LastRow As Long
Dim erow As Long
Dim i As Long
Dim strComponent
Dim strVessel
Dim intOil As Long
LastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
Sheet1.Select
Range("A1").Select
'Cape Henlopen, Fuel Consumption, February
For i = 2 To LastRow
mydate = Cells(i, 3)
strVessel = Cells(i, 1)
strComponent = Cells(i, 2)
If InStr(1, strComponent, "Fuel Consumed") And InStr(1, strVessel, "Cape Henlopen") And mydate >= "2018-02-01" And mydate <= "2018-02-29" Then
erow = Sheet4.Cells(Rows.Count, 9).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 3), Cells(i, 4)).Copy Destination:=Sheet4.Range("I" & erow)
End If