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 = 1 (until there is no more data in column A)
If the value of cell Ax > cell Bx then cell Bx = cell Ax
If the value of cell Ax < cell Cx then cell Cx = cell Ax
x = x + 1
End Do

All my attempts fail.
Thanks,
Wes
 
I

isabelle

hi Wes,

Sub Macro1()
Dim LastRow As Long, i As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
If .Range("A" & i) > .Range("B" & i) Then
.Range("B" & i) = .Range("A" & i).Value
ElseIf .Range("A" & i) < .Range("B" & i) Then
.Range("C" & i) = .Range("A" & i).Value
Else
'what is equal
End If
Next
End With
End Sub

isabelle

Le 2013-03-04 21:34, Wes Finch a écrit :
 
W

Wes Finch

hi Wes,



Sub Macro1()

Dim LastRow As Long, i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row

For i = 1 To LastRow

If .Range("A" & i) > .Range("B" & i) Then

.Range("B" & i) = .Range("A" & i).Value

ElseIf .Range("A" & i) < .Range("B" & i) Then

.Range("C" & i) = .Range("A" & i).Value

Else

'what is equal

End If

Next

End With

End Sub



isabelle



Le 2013-03-04 21:34, Wes Finch a écrit :

Thanks isabelle,
This works great!
You have saved me much stress.
Wes
 
I

isabelle

glad to help. thanks for the feedback.

isabelle

Le 2013-03-04 22:34, Wes Finch a écrit :
 

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