Finding and Pasting Below

JFuller

New Member
Joined
May 11, 2022
Messages
13
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
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.

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
ABCDEFGHIJK
1Base Margin0.6
2Options Margin0.55
3Base Labor Rate95
4Options Labor Rate100
5
6
7
8
9OptionDescriptionExport (X) $$1 $$2 $$1 $$2
10BIDx
11O1 (+)x$ 4,203.00$ 4,203.00
12O1 (-)x$ 4,203.00$ 4,203.00
13O1x
14O2 (+)$ 4,203.00$ 4,203.00
15O2 (-)$ 4,203.00$ 4,203.00
16O2x
17O3 (+)x$ 4,203.00$ 4,203.00
18O3 (-)x$ 4,203.00$ 4,203.00
19O3x
20O4 (+)0$ 4,203.00$ 4,203.00
21O4 (-)0$ 4,203.00$ 4,203.00
22O4
23O5 (+)0$ 4,203.00$ 4,203.00
24O5 (-)0$ 4,203.00$ 4,203.00
25O5
26O6 (+)0$ 4,203.00$ 4,203.00
27O6 (-)0$ 4,203.00$ 4,203.00
28O6
29O7 (+)0$ 4,203.00$ 4,203.00
30O7 (-)0$ 4,203.00$ 4,203.00
31O7
32O8 (+)0$ 4,203.00$ 4,203.00
33O8 (-)0$ 4,203.00$ 4,203.00
34O8
35O9 (+)0$ 4,203.00$ 4,203.00
36O9 (-)0$ 4,203.00$ 4,203.00
Sheet1
Cell Formulas
RangeFormula
H10H10=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:G15G11=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:H15H11=VLOOKUP(GRAND_TOTAL_BID,Sheet2!C:S,17,FALSE)
E17,E35,E32,E29,E26,E23,E20E17=E19
E18,E36,E33,E30,E27,E24,E21E18=E19
Named Ranges
NameRefers ToCells
GRAND_TOTAL_BID=Sheet2!$C$49G35:H36, G32:H33, G29:H30, G26:H27, G23:H24, G20:H21, G17:H18, G14:H15, G11:H12
Cells with Data Validation
CellAllowCriteria
E10:E36Listx,X


Excel_Forum - Find Value and Paste X Below It - Copy (2).xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1O1 (+)O1 (-)O2 (+)O2 (-)
2LABOR TOTALUnit PriceMATERIALXXXX
31
419$1.00$19.00$1.00$1.00$19.001468
523$1.00$23.00$1.00$1.00$23.002579
627$1.00$27.00$1.00$1.00$27.0036810
731$1.00$31.00$1.00$1.00$31.0047911
835$1.00$35.00$1.00$1.00$35.00581012
Sheet2
Cell Formulas
RangeFormula
N4:N8N4=M4*J4
O4:O8O4=ROUND((Q4+R4+P4)/$O$3,2)
AE4:AE8AE4=IF($AE$2="X",INDIRECT(TEXT("'"&$AE$1&"'"&"!J"&ROW(),"text")),0)
AF4:AF8AF4=IF($AF$2="X",INDIRECT(TEXT("'"&$AF$1&"'"&"!J"&ROW(),"text")),0)
AG4:AG8AG4=IF($AG$2="X",INDIRECT(TEXT("'"&$AG$1&"'"&"!J"&ROW(),"text")),0)
AH4:AH8AH4=IF($AH$2="X",INDIRECT(TEXT("'"&$AH$1&"'"&"!J"&ROW(),"text")),0)
J4:J8J4=SUM(AE4:AH4)
S4:S8S4=J4*O4
Named Ranges
NameRefers ToCells
OPTIONSRANGE=Sheet2!$AE$1:$AH$1AE4:AE8
Cells with Conditional Formatting
CellConditionCell FormatStop If True
T4:T46Expression=#REF!="PTK"textNO
H4:I46Expression=OR(F30="PKT",F30="BP",F30="BF2",F30="BF4")textNO
Cells with Data Validation
CellAllowCriteria
T3:T46List=DOOR_PREP
U3ListHARDWARE_COLOR
U4:U46List=HARDWARE_COLOR
F4:F20List=DOOR_TYPE
G4:G20List=JAMB_DEPTH
H4:H16List=SPECIES
I4:I16List=DR_SWING
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,566
Messages
6,125,597
Members
449,238
Latest member
wcbyers

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