Convert to Excel Macro

W

Wes Finch

Hi all, I need some help here.

I need this logic converted to an excel 2003 macro:

Current.worksheet
Do x = 6 by 1 (until there is no more data in column A)
If the cell value Ax > cell value Bx then cell value Bx = cell value Ax
If the cell value Ax < cell value Cx then cell value Cx = cell value Ax
End Do

All my feeble attempts fail.
Thanks,
Wes
 
W

Wes Finch

Thanks Mike,
It works great with just one minor modification as the cells would be empty on the first run:

If Cells(x, 1) < Cells(x, 3) Or IsEmpty(Cells(x, 2)) Then

I appreciate your help.
Wes
 
W

Wes Finch

Give this a try:



Sub marine()

Dim N As Long, x As Long

N = Cells(Rows.Count, "A").End(xlUp).Row

For x = 6 To N

If Cells(x, 1) > Cells(x, 2) Then

Cells(x, 2) = Cells(x, 1)

End If

If Cells(x, 1) < Cells(x, 3) Then

Cells(x, 3) = Cells(x, 1)

End If

Next x

End Sub

Thanks MIke!
I got it working!
 

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