Acting on all cells in a given set

stooven

New Member
Joined
Oct 12, 2006
Messages
15
This question may be a bit easy but I haven't been at this long. I have this loop:

Code:
    For Each cell In aRange.SpecialCells(xlCellTypeVisible)
        If [H1].Value = "COMMERCIAL PAPER" Then
            [C1].Value = [N1].Value
        End If
    Next cell

I want every visible row to be looked at and acted on in this way instead of just row 1, as I have above. I can't seem to get the notation right. I would appreciate any advice.

Thanks,
Steve
(excel 97)
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,915
Office Version
  1. 365
Platform
  1. Windows
Steve

It's pretty hard to advise here since we don't know what aRange actually is and you don't actually refer to cell within the loop.

If you just want to change the value in one column based on the value in another then you probably don't even need to loop in the first place.
 

stooven

New Member
Joined
Oct 12, 2006
Messages
15
Hello again, Norie
I got rid of the loop in my other script (a few posts ago) like you said and it got rid of the 2-3 minute runtime. This new operation will only be done on a few rows so Im not as worried about runtime but If it makes for a better all around script, Id rather be doing things the right way for learning purposes.

As for this script, yes you're right: I want to change the value in one column based on the value in another. This is the gist of it:

If the value in column H, row 2 = (COMMERCIAL PAPER) then I want the value in Column C, row 2 to be set to the value in Column N, row 2.

Thanks again,
Steve
 

Watch MrExcel Video

Forum statistics

Threads
1,113,916
Messages
5,545,022
Members
410,647
Latest member
bernardazar
Top