Jarrah
Jarrah

Reputation: 11

If a cell has a value move adjacent cell to that location

I have some data that looks like this:

Upstream    6.36
Downstream  6.25
Downstream  6.36
Upstream    6.25

What I want is, if the cell says Upstream, replace the word Upstream with the value in the cell next to it e.g.6.36.

Upvotes: 0

Views: 131

Answers (2)

John
John

Reputation: 159

You could use some code like the following to do what you want:

Dim i As Integer

For i = 1 To 4
    If Cells(i, 1).Value = "Upstream" Then
        Cells(i, 1).Value = Cells(i, 2)
    End If
Next i

Upvotes: 1

pnuts
pnuts

Reputation: 59485

Assuming first Upstream is in A1 and first 6.36 in B1, a simple formula might be sufficient. Insert a column between the two existing and in B1:

=IF(A1="Upstream",C1,A1)  

copied down to suit. Select ColumnB, Copy, Paste Special, Values over the top and delete ColumnA.

Upvotes: 0

Related Questions