View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
excelent excelent is offline
external usenet poster
 
Posts: 695
Default New to macros - find/move question

ok try

Sub Move()
Range(("A1"), Range("A65500").End(xlUp)).Select
For Each x In Selection
If x.Value Like "test*" Or x.Value Like "data*" Then
x.Copy Destination:=x.Offset(-1, 1)
x.EntireRow.Delete
End If
Next
End Sub


"n412" skrev:

That is exactly what is happening.

If the cell contains only 'test' or 'data', the macro works perfectly.
However, the cells only begin with 'test' or 'data' and have other
words after them - ex. "Data no 1".

Any way to make this macro work with an IF/Then that if x.value
CONTAINS or BEGINS with 'test' or 'data' instead of equals?


Thanks again.


n412 wrote:
Thank you for the response.

I tried the code, and all it seems to do is select all the cells in
Column A that contain data. Nothing is getting cut/pasted.

Not sure if this has anything to do with it, but the cells that contain
"test" or "data" contain other text as well - but they do begin with
"test" or "data".


Thank you.


excelent wrote:
try this,- remember to make backup first right :-)

Sub Move()
Range(("A1"), Range("A65500").End(xlUp)).Select
For Each x In Selection
If x.Value = "test" Or x.Value = "data" Then
x.Copy Destination:=x.Offset(-1, 1)
x.EntireRow.Delete
End If
Next
End Sub