finding cell with + and sorting

C

CR

I have a range of T14:W29

Starting in T14 The values read across the rows T - U - V - W

A+ needs to keep the 20 and B needs to keep the 15, ect. The values are,
(with - separating the columns) for example:

T - U - V - W

A +2 - 20 - 15 - B

CD - 10 - 5 - E +4

B - 11 - 4 - J +9

YRB +6 - 3 - 7 - Q

What I need to do is identify the cells with the + and copy everything to an
new range starting at T38 so the end result looks like:

B - 15 - 20 - A +2

CD - 10 - 5 - E +4

B - 11 - 4 - J +9

Q - 7 - 3 - YRB +6

All of the cells that have a + in them need to be in "W" with their
corresponding numbers in "V"
All of the cells that have no + need to be in "T" with their corresponding
numbers in "U"

I hope I have explained this clearly enough.

Thanks'
CR
 
R

Rick Rothstein

Does this macro do what you want?

Sub MoveData()
Dim X As Long, Z As Long
Z = 38
For X = 14 To 29
If InStr(Cells(X, "T").Value, "+") Then
Cells(Z, "W").Value = Cells(X, "T").Value
Cells(Z, "V").Value = Cells(X, "U").Value
Cells(Z, "T").Value = Cells(X, "W").Value
Cells(Z, "U").Value = Cells(X, "V").Value
Z = Z + 1
Else
Range("T" & X & ":W" & X).Copy Range("T" & Z)
Z = Z + 1
End If
Next
End Sub
 
C

CR

Yes, it does.
Thank you!!


Rick Rothstein said:
Does this macro do what you want?

Sub MoveData()
Dim X As Long, Z As Long
Z = 38
For X = 14 To 29
If InStr(Cells(X, "T").Value, "+") Then
Cells(Z, "W").Value = Cells(X, "T").Value
Cells(Z, "V").Value = Cells(X, "U").Value
Cells(Z, "T").Value = Cells(X, "W").Value
Cells(Z, "U").Value = Cells(X, "V").Value
Z = Z + 1
Else
Range("T" & X & ":W" & X).Copy Range("T" & Z)
Z = Z + 1
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top