ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop through rows evaluating 2 cells (https://www.excelbanter.com/excel-programming/335664-loop-through-rows-evaluating-2-cells.html)

mthomas

loop through rows evaluating 2 cells
 

I am building a utility that will allow the user to iterate down a
undermined amount of rows. The script needs to evaluate the followin
on the active row: If the active cell in column a < "" and the activ
cell in column k = "" then the active cell in column k = k4.value.

Thanks in advance for your assistance! :rolleyes

--
mthoma
-----------------------------------------------------------------------
mthomas's Profile: http://www.excelforum.com/member.php...fo&userid=2564
View this thread: http://www.excelforum.com/showthread.php?threadid=39058


Tom Ogilvy

loop through rows evaluating 2 cells
 
Sub ABCD()
Dim i as Long, lastrow as Long
lastrow = cells(rows.count,1).End(xlup).row
for i = 5 to Lastrow
if cells(i,1).Value < "" and cells(i,"K").Value = "" then
cells(i,"K").value = cells(4,"K").value
end if
Next i
End sub

--
Regards,
Tom Ogilvy
"mthomas" wrote in
message ...

I am building a utility that will allow the user to iterate down an
undermined amount of rows. The script needs to evaluate the following
on the active row: If the active cell in column a < "" and the active
cell in column k = "" then the active cell in column k = k4.value.

Thanks in advance for your assistance! :rolleyes:


--
mthomas
------------------------------------------------------------------------
mthomas's Profile:

http://www.excelforum.com/member.php...o&userid=25649
View this thread: http://www.excelforum.com/showthread...hreadid=390580




mthomas[_2_]

loop through rows evaluating 2 cells
 

Tom,

Thanks for the reply and it works! But could you please explain wha
this line is doing....

lastrow = cells(rows.count,1).End(xlup).row

Thanks again for you help on this and have a great day

--
mthoma
-----------------------------------------------------------------------
mthomas's Profile: http://www.excelforum.com/member.php...fo&userid=2564
View this thread: http://www.excelforum.com/showthread.php?threadid=39058


Tom Ogilvy

loop through rows evaluating 2 cells
 
If you went to the bottom of the worksheet (or any cell past you data ) and
selected a cell, then hit the END key , then the Up Arrow, the selection
would move to the last cell in that column containing data or a formula.
That is what the code does - finds the last cell in the column containing
data or a formula and returning the row number of that cell.

--
Regards,
Tom Ogilvy

"mthomas" wrote in
message ...

Tom,

Thanks for the reply and it works! But could you please explain what
this line is doing....

lastrow = cells(rows.count,1).End(xlup).row

Thanks again for you help on this and have a great day!


--
mthomas
------------------------------------------------------------------------
mthomas's Profile:

http://www.excelforum.com/member.php...o&userid=25649
View this thread: http://www.excelforum.com/showthread...hreadid=390580





All times are GMT +1. The time now is 02:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com