Macro to find/paste/delete/next

JFuller

New Member
Joined
May 11, 2022
Messages
13
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello -

I have a start on a macro but I dont think its working correctly.

On the "OPTIONS" sheet, I want the macro to look in cells E10:E190 for an "X". If found, then lookup the string in A10:A190 (the corresponding row to where the "X" was found), go to the "OPTIONSRANGE" and paste an "X" below that value found. Then, delete that X that was just placed and start on the next row. Thank you in advance!!

VBA Code:
Option Explicit

Sub O_bbb()


    Const sSht = "OPTIONS"
    Const sCell_1 = "A11"
    Const sCell_2 = "A12"

    Const fSht = "MAIN (OPT_PRICING)"
    Const fRng = "OPTIONSRANGE"
    Const fMrkr = "X"

    Dim fCell As Range
    Dim sVle_1, sVle_2

    With ActiveWorkbook
        sVle_1 = .Sheets(sSht).Range(sCell_1).Value
        sVle_2 = .Sheets(sSht).Range(sCell_2).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
            End With
        End With
    End With

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
then lookup the string in A10:A190 (the corresponding row to where the "X" was found), go to the "OPTIONSRANGE" and paste an "X" below that value found.
Hello!

Could you post a little example of your tables before and after macro please?
 
Upvote 0
Hey LazyBug!

so in the first picture here, we're looking in the column titled "Export (X)" for an X. if found, we go to Column A (Option) and pull that string (for row 11 we'd say "01 (+)." Then look for that in the second screenshot and put an x below it. then delete the x that was just placed and start with the next row (12).

A little added insight, I want to sneak in an operation but I was going to try breaking this project into pieces to make it easier to get help on. After row 11 is analyzed and the X placed in the range, i'd like to copy G11 and H11 (from the OPTIONS tab), and paste them into I11 and J11 (paste values). then delete the X out of the range and start on row 12, and so on.

excel1.png
excel2.png
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,861
Members
449,472
Latest member
ebc9

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