arpaprocki
New Member
- Joined
- Sep 7, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- 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.
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!
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!