Need help with Identifying New Variables, Selecting Associated Unidentified Cells, & Identifying Beginning and End Dates

arpaprocki

New Member
Joined
Sep 7, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello! I have created a macro that reads through data and copies associated data based on if conditions are met. I was able to do this for the first loop through the data because the cells the data is copied from will be the same, but once it moves from that initial cell, the cell address that the macro will need to copy will become inconsistent.

1662579141977.png
1662579420203.png


I have set "x" to be the product ID and based on that, I want it to copy and paste the information in J2:J5. Once I get to line 17, the product ID changes. I need the macro to identify that the product ID is different from the original "x" and set the new product ID to be the new "x" (or another variable). From there I need it to copy and paste the data from J17:J20. I cannot use this specific cell address though because when I import data into the source sheet, the different product IDs will be in different rows (i.e. the product ID may be the same for 9/8 but change on 9/9). Is there a way to make the macro grab the four cells of information without using a specific cell address?

I also need to copy and paste the first date that a product ID shows and the last date for a 5 date range. The current image shows 5 days but continues to show until 9/18. How can I make it so that it will only keep the first 5 days that fall under the line number (column C, below are additional lines BU_L8Puf, BU_L9Puf, etc.)? From there how can I copy the first date in which a product ID shows and the last date. For the 123456 product ID, I need to copy 9/8 and 9/10.

Thanks in advance!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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