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

Thank you - that did the trick.

A couple more questions, I am searching for about 15 values through
10000 lines of code. It takes about 4 minutes or so for the macro to
run. Is that normal, or is there a different way I should be doing
this based on the number of values I'm searching for.

Also, I've got a bunch of blank rows in my spreadsheet I'd like to
delete. I tried adding as ElseIf x.Value = "" Then x.EntireRow.Delete,
but that did not get rid of the rows.





excelent wrote:
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