How to loop through a range of cells

Lorna

New Member
Joined
Mar 12, 2009
Messages
19
I have a range of cells (L3:L10) on a sheet called Products. Each of the cells in this range gets it's value based on an IF statement. So the list may look something like this:

Item Codes
11702-71-21
0
11702-73-21
0
0
11702-76-21
0
11702-97-21

I have another sheet called Order Form and the range C:3:C10 is where I want the Items Codes on the Products sheet to be displayed. However, I only want to display on the Order Form just the fields with actual item codes. So what would be the easiest way to loop through this range and only pick out the valid item codes and disregard the cells with only a 0?

Thanks
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Lorna,

You could record a macro here - how about filtering the column to exclude zero and blank values and then copying over the visible cells? This way you won't need to use a loop.

Hope that helps
 

Lorna

New Member
Joined
Mar 12, 2009
Messages
19
I hadn't thought of doing that...much simpler and it works just fine. Many thanks Colin.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,694
Messages
5,597,571
Members
414,156
Latest member
WDMix

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