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)
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
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
 

Forum statistics

Threads
1,140,937
Messages
5,703,264
Members
421,289
Latest member
fbohlandt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top