ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search / Copy / Paste (https://www.excelbanter.com/excel-programming/367147-search-copy-paste.html)

RigasMinho

Search / Copy / Paste
 
Here's my situation:

I have one spreadsheet with 2 columns in them.

Column 1 has values of data
Column 2 has the key codes for the data.

Example:
column 1:
Telephone
TV
Video Camera

Column 2:
A
B
C

cell A1 value: Telphone
cell A2 value: TV
Cell A3 value: Video Camera

Cell B1 value: A
Cell B2 value: B
Cell B3 value: C


I want to be able to create a macro that will search Column 2. Say I
search for the value "A"

The output should be "Telephone" into another cell.

So the steps I need is:
Macro to search for the value from Column 2
Macro to select the value in Column 1 when result is found
Macro to paste the value in Column 1 onto a new cell.

I was thinking of using a command button that you can load in using the
form function in excel.


Die_Another_Day

Search / Copy / Paste
 
VBA is not needed. C1 = Value to search for D1 = =INDIRECT("A" &
MATCH(C1,B:B,0))
Note: The match function returns the position of the search item in the
array, therefore if the array does not start with Row 1 then you will
have to correct for that.

Regards,

Die_Another_Day
RigasMinho wrote:
Here's my situation:

I have one spreadsheet with 2 columns in them.

Column 1 has values of data
Column 2 has the key codes for the data.

Example:
column 1:
Telephone
TV
Video Camera

Column 2:
A
B
C

cell A1 value: Telphone
cell A2 value: TV
Cell A3 value: Video Camera

Cell B1 value: A
Cell B2 value: B
Cell B3 value: C


I want to be able to create a macro that will search Column 2. Say I
search for the value "A"

The output should be "Telephone" into another cell.

So the steps I need is:
Macro to search for the value from Column 2
Macro to select the value in Column 1 when result is found
Macro to paste the value in Column 1 onto a new cell.

I was thinking of using a command button that you can load in using the
form function in excel.




All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com