Hello!
I have experience writing Macros for Excel, but I cannot seem to figure out how to perform an operation. I hope that someone here will be more familiar with the syntax and passing of parameters to help.
I have two nonadjacent columns; C and F. I would like to find the maximum of two cells in the same row and assign the value to another cell (same row) in J; up to a certain row.
For example:
____C____ F____ J
1|__0____ 5____ 5
2|__10___ 9____ 10
3|__1____Null___1
4|__Null__63____63
What I have so far is something along the lines of:
Sub Max()
Dim rownum
rownum = 1 'starting row position
Do While rownum <= 4 'final operation taking place at row 4
Range("J" & rownum).Value = Max(Range("C" & rownum).Value,Range("F" & rownum).Value) 'trying to assign the max value of two cells to a third cell
rownum = rownum + 1 'incrementing row number by one to proceed to next rowLoop
End Sub
I could do this with a few IF statements, but my goal is to do it in a single line. I don't see why it couldn't be done. I just think my syntax for passing the Value parameter to the Max function is incorrect. Nor do I believe that I am calling the Max function properly.
*The reason for not simply typing in a formula into the cells as "=Max(C1,F1)" is because I have around 500 rows of data, not every single row has data, i.e. C and F may both be Null, and I will be using this to perform another function to assign a different value to J later on.
Bookmarks