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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Colin Legg

MrExcel MVP
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,879
Messages
5,834,217
Members
430,264
Latest member
ddeboor

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