Macro to list only choosen cells

TorrO

Board Regular
Joined
Feb 13, 2003
Messages
118
Office Version
  1. 2013
Platform
  1. Windows
Hi

can I get some help to make a macro?

The macro that reads column J (Pick) if there is an 'x', then return adjacent cell value in column K(Data) to a list in column M (result)


SIA F calculation program V1.xlsx
JKLM
3PickDataResult
4xCarCar
5HouseCat
6xCatDog
7xDog
8Cabin
Std Txt 2020.09.13
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try:
VBA Code:
Sub torrO()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim pick As Range
    For Each pick In Range("J4:J" & LastRow)
        If pick = "x" Then
            Cells(Rows.Count, "M").End(xlUp).Offset(1) = pick.Offset(, 1)
        End If
    Next pick
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Here is another macro (a non-looping one-liner) that should also work...
VBA Code:
Sub GetValuesMarkedWithX()
  Intersect(Range("J4:J" & Rows.Count).SpecialCells(xlConstants).EntireRow, Columns("K")).Copy Range("M4")
End Sub
 
Upvote 0
Thanks Rick Rothstein

Your macro also copied format from original text. That was a relief since this is a sheet that i try to automate as much as possible.
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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