Counter for coordinating dates and transferring data to other sheets

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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
As I understand your request the following should work:
Change
Code:
erow = Sheet4.Cells(Rows.Count, 9).End(xlUp).Offset(1, 0).Row
to
Code:
erow = Day(mydate)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top