I am really stuck on a long project that I have been working on. This is the next to the last step; I need to complete this project. In VBA I am looking to do the following.
IF
data in Sheet1 any row, columns A,B,C is = to data Sheet 2, any row columns A,B,C,
AND
Sheet1 (matched row) column D is, => than Sheet2 (matched row) column D
AND
Sheet1 (matched row) column E is, > than 0
AND
Sheet2 (matched row) column E is, > than 0
THEN DO THIS
STEP 1
COPY Sheet1 (match) columns A,B,C to Sheet3 next available row columns A,B,C
STEP 2
1. “In Sheet1” SUBTRACT Sheet2 (match) column D from Sheet1 (match) column D
2. COPY Sheet2 (match) column D to Sheet3 column D (same row as above)
STEP 3
IF
Sheet1 (match) Column E is =< Sheet2 (match) Column E
Then
1. Copy Sheet1 (match) Column E to Sheet3 Column E (same row as above)
2. Subtract Sheet1 (match) Column E from Sheet2 Column E
3. Delete entire row Sheet1 (match)
Elseif
Sheet1 (match) Column E is > Sheet2 (match) Column E
Then
1. Subtract Sheet2 (match) Column E from Sheet1 (match) Column E
2. Copy Sheet2 (match) Column E to Sheet3 (same row as above)
3. Delete entire row Sheet2 (match)
STEP 4
LOOP until no data is found.
To help speed up the loop (if needed) the maximum number of rows will never be more than 150, so you could just loop the first 150 rows if it is easier to write the code.
I can post some sample data if needed, column A is TEXT, the rest of the data is numeric with possible of 3 decimal places.
Like this
A = “Copper”
B = 48.375
C= 120
D= 14.375
E= 2500
I know this is A LOT of code to write. Any help would really be appreciated. I am learning how to write in VBA but this is way beyond my level.
Steve
IF
data in Sheet1 any row, columns A,B,C is = to data Sheet 2, any row columns A,B,C,
AND
Sheet1 (matched row) column D is, => than Sheet2 (matched row) column D
AND
Sheet1 (matched row) column E is, > than 0
AND
Sheet2 (matched row) column E is, > than 0
THEN DO THIS
STEP 1
COPY Sheet1 (match) columns A,B,C to Sheet3 next available row columns A,B,C
STEP 2
1. “In Sheet1” SUBTRACT Sheet2 (match) column D from Sheet1 (match) column D
2. COPY Sheet2 (match) column D to Sheet3 column D (same row as above)
STEP 3
IF
Sheet1 (match) Column E is =< Sheet2 (match) Column E
Then
1. Copy Sheet1 (match) Column E to Sheet3 Column E (same row as above)
2. Subtract Sheet1 (match) Column E from Sheet2 Column E
3. Delete entire row Sheet1 (match)
Elseif
Sheet1 (match) Column E is > Sheet2 (match) Column E
Then
1. Subtract Sheet2 (match) Column E from Sheet1 (match) Column E
2. Copy Sheet2 (match) Column E to Sheet3 (same row as above)
3. Delete entire row Sheet2 (match)
STEP 4
LOOP until no data is found.
To help speed up the loop (if needed) the maximum number of rows will never be more than 150, so you could just loop the first 150 rows if it is easier to write the code.
I can post some sample data if needed, column A is TEXT, the rest of the data is numeric with possible of 3 decimal places.
Like this
A = “Copper”
B = 48.375
C= 120
D= 14.375
E= 2500
I know this is A LOT of code to write. Any help would really be appreciated. I am learning how to write in VBA but this is way beyond my level.
Steve