Hello -
I am using the following code to look at a value in column A, then find that value in a range on sheet2 and paste an X below it.
I would like some help adding a few things:
--Macro would validate if there is an "X" in column E, sheet1
--If found, Macro would go to corresponding same row in Column A
--Use the found value to go to that sheet, and paste an X in the range below that value
--then on that same row back on sheet1, copy column G cell and paste value in column I cell
--then on that same row in sheet1, copy column H cell and paste value in column J cell
--then clear out the X that was just placed on sheet2 and start the look back on sheet1, column E again (next row)
Thank you!
I am using the following code to look at a value in column A, then find that value in a range on sheet2 and paste an X below it.
VBA Code:
Option Explicit
Sub bbb()
Sub bbb()
Const sSht = "Sheet1"
Const sCell_1 = "A11"
Const sCell_2 = "A12"
Const sCell_3 = "A14"
Const sCell_4 = "A15"
Const fSht = "Sheet2"
Const fRng = "OptionsRange"
Const fMrkr = "X"
Dim fCell As Range
Dim sVle_1, sVle_2, sVle_3, sVle_4
With ActiveWorkbook
sVle_1 = .Sheets(sSht).Range(sCell_1).Value
sVle_2 = .Sheets(sSht).Range(sCell_2).Value
sVle_3 = .Sheets(sSht).Range(sCell_3).Value
sVle_4 = .Sheets(sSht).Range(sCell_4).Value
With .Sheets(fSht)
With .Range(fRng)
Set fCell = .Find(sVle_1, , xlFormulas, xlWhole, xlByColumns)
If Not fCell Is Nothing Then fCell.Offset(1, 0).Value = fMrkr
Set fCell = .Find(sVle_2, , xlFormulas, xlWhole, xlByColumns)
If Not fCell Is Nothing Then fCell.Offset(1, 0).Value = fMrkr
Set fCell = .Find(sVle_3, , xlFormulas, xlWhole, xlByColumns)
If Not fCell Is Nothing Then fCell.Offset(1, 0).Value = fMrkr
Set fCell = .Find(sVle_4, , xlFormulas, xlWhole, xlByColumns)
If Not fCell Is Nothing Then fCell.Offset(1, 0).Value = fMrkr
End With
End With
End Sub
I would like some help adding a few things:
--Macro would validate if there is an "X" in column E, sheet1
--If found, Macro would go to corresponding same row in Column A
--Use the found value to go to that sheet, and paste an X in the range below that value
--then on that same row back on sheet1, copy column G cell and paste value in column I cell
--then on that same row in sheet1, copy column H cell and paste value in column J cell
--then clear out the X that was just placed on sheet2 and start the look back on sheet1, column E again (next row)
Thank you!
Excel_Forum - Find Value and Paste X Below It - Copy (2).xlsm | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | |||
1 | Base Margin | 0.6 | |||||||||||
2 | Options Margin | 0.55 | |||||||||||
3 | Base Labor Rate | 95 | |||||||||||
4 | Options Labor Rate | 100 | |||||||||||
5 | |||||||||||||
6 | |||||||||||||
7 | |||||||||||||
8 | |||||||||||||
9 | Option | Description | Export (X) | $$1 | $$2 | $$1 | $$2 | ||||||
10 | BID | x | |||||||||||
11 | O1 (+) | x | $ 4,203.00 | $ 4,203.00 | |||||||||
12 | O1 (-) | x | $ 4,203.00 | $ 4,203.00 | |||||||||
13 | O1 | x | |||||||||||
14 | O2 (+) | $ 4,203.00 | $ 4,203.00 | ||||||||||
15 | O2 (-) | $ 4,203.00 | $ 4,203.00 | ||||||||||
16 | O2 | x | |||||||||||
17 | O3 (+) | x | $ 4,203.00 | $ 4,203.00 | |||||||||
18 | O3 (-) | x | $ 4,203.00 | $ 4,203.00 | |||||||||
19 | O3 | x | |||||||||||
20 | O4 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
21 | O4 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
22 | O4 | ||||||||||||
23 | O5 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
24 | O5 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
25 | O5 | ||||||||||||
26 | O6 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
27 | O6 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
28 | O6 | ||||||||||||
29 | O7 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
30 | O7 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
31 | O7 | ||||||||||||
32 | O8 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
33 | O8 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
34 | O8 | ||||||||||||
35 | O9 (+) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
36 | O9 (-) | 0 | $ 4,203.00 | $ 4,203.00 | |||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
H10 | H10 | =IF(C10="X",VLOOKUP("GRAND_TOTAL_BID",#REF!,17,FALSE),"") |
G11:G12,G35:G36,G32:G33,G29:G30,G26:G27,G23:G24,G20:G21,G17:G18,G14:G15 | G11 | =VLOOKUP(GRAND_TOTAL_BID,Sheet2!C:S,12,FALSE) |
H11:H12,H35:H36,H32:H33,H29:H30,H26:H27,H23:H24,H20:H21,H17:H18,H14:H15 | H11 | =VLOOKUP(GRAND_TOTAL_BID,Sheet2!C:S,17,FALSE) |
E17,E35,E32,E29,E26,E23,E20 | E17 | =E19 |
E18,E36,E33,E30,E27,E24,E21 | E18 | =E19 |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
GRAND_TOTAL_BID | =Sheet2!$C$49 | G35:H36, G32:H33, G29:H30, G26:H27, G23:H24, G20:H21, G17:H18, G14:H15, G11:H12 |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
E10:E36 | List | x,X |
Excel_Forum - Find Value and Paste X Below It - Copy (2).xlsm | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | AE | AF | AG | AH | |||
1 | O1 (+) | O1 (-) | O2 (+) | O2 (-) | ||||||||||||||||||||||||||||||||
2 | LABOR TOTAL | Unit Price | MATERIAL | X | X | X | X | |||||||||||||||||||||||||||||
3 | 1 | |||||||||||||||||||||||||||||||||||
4 | 19 | $1.00 | $19.00 | $1.00 | $1.00 | $19.00 | 1 | 4 | 6 | 8 | ||||||||||||||||||||||||||
5 | 23 | $1.00 | $23.00 | $1.00 | $1.00 | $23.00 | 2 | 5 | 7 | 9 | ||||||||||||||||||||||||||
6 | 27 | $1.00 | $27.00 | $1.00 | $1.00 | $27.00 | 3 | 6 | 8 | 10 | ||||||||||||||||||||||||||
7 | 31 | $1.00 | $31.00 | $1.00 | $1.00 | $31.00 | 4 | 7 | 9 | 11 | ||||||||||||||||||||||||||
8 | 35 | $1.00 | $35.00 | $1.00 | $1.00 | $35.00 | 5 | 8 | 10 | 12 | ||||||||||||||||||||||||||
Sheet2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
N4:N8 | N4 | =M4*J4 |
O4:O8 | O4 | =ROUND((Q4+R4+P4)/$O$3,2) |
AE4:AE8 | AE4 | =IF($AE$2="X",INDIRECT(TEXT("'"&$AE$1&"'"&"!J"&ROW(),"text")),0) |
AF4:AF8 | AF4 | =IF($AF$2="X",INDIRECT(TEXT("'"&$AF$1&"'"&"!J"&ROW(),"text")),0) |
AG4:AG8 | AG4 | =IF($AG$2="X",INDIRECT(TEXT("'"&$AG$1&"'"&"!J"&ROW(),"text")),0) |
AH4:AH8 | AH4 | =IF($AH$2="X",INDIRECT(TEXT("'"&$AH$1&"'"&"!J"&ROW(),"text")),0) |
J4:J8 | J4 | =SUM(AE4:AH4) |
S4:S8 | S4 | =J4*O4 |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
OPTIONSRANGE | =Sheet2!$AE$1:$AH$1 | AE4:AE8 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
T4:T46 | Expression | =#REF!="PTK" | text | NO |
H4:I46 | Expression | =OR(F30="PKT",F30="BP",F30="BF2",F30="BF4") | text | NO |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
T3:T46 | List | =DOOR_PREP |
U3 | List | HARDWARE_COLOR |
U4:U46 | List | =HARDWARE_COLOR |
F4:F20 | List | =DOOR_TYPE |
G4:G20 | List | =JAMB_DEPTH |
H4:H16 | List | =SPECIES |
I4:I16 | List | =DR_SWING |