ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find THIS and move it HERE (https://www.excelbanter.com/excel-programming/292738-find-move-here.html)

Green

Find THIS and move it HERE
 
Im having some problems with a macro im trying to build and i was hopin
one of you would have an answer for me.
I have a series of databases in Excel that contain a different amoun
of records of varying length. I would like to know the best way t
scan all the data for a cell that contains one of about 20 differen
processing codes, cut the value and paste it to column AJ in the sam
row the data was found.

So its....

Do
IF (current field) contains (one of my codes)
THEN move (data in current field) to column AJ
WHILE (database has more data)

I appreciate any help anyone can give

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Find THIS and move it HERE
 
Hi
try the following (processes the current selection)

Sub foo()
Dim rng As Range
Dim rng As Range
Dim cell As Range

Set rng = Selection
For Each cell In rng
Select Case cell.Value
Case "code1", "code2", "code3"
Cells(cell.row, "AJ").Value = cell.Value
Case Else
'do nothing
End Select
Next
End Sub



--
Regards
Frank Kabel
Frankfurt, Germany

Im having some problems with a macro im trying to build and i was
hoping one of you would have an answer for me.
I have a series of databases in Excel that contain a different amount
of records of varying length. I would like to know the best way to
scan all the data for a cell that contains one of about 20 different
processing codes, cut the value and paste it to column AJ in the same
row the data was found.

So its....

Do
IF (current field) contains (one of my codes)
THEN move (data in current field) to column AJ
WHILE (database has more data)

I appreciate any help anyone can give.


---
Message posted from http://www.ExcelForum.com/



green78[_2_]

Find THIS and move it HERE
 
Hi, thank you ! I also needed this one. But can you pls explain furthe
- what if I want:

IF (code) is (part of cell content)
THEN (move to column AJ)

The macro you pasted above works only if it is a full match. Thank you

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Find THIS and move it HERE
 
Hi
try
If InStr(cell.value,code) then...

--
Regards
Frank Kabel
Frankfurt, Germany

Hi, thank you ! I also needed this one. But can you pls explain
further - what if I want:

IF (code) is (part of cell content)
THEN (move to column AJ)

The macro you pasted above works only if it is a full match. Thank
you.


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 12:35 AM.

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