How to loop though a range of cells and if it is false to skip to search the next row, rather than insert my false result

Eyale

New Member
Joined
Jan 23, 2019
Messages
9
Hello there experts,

I have the following code that successfully returns the values of any cells in column A starting with a letter A to Z:

=IF(AND(CODE(UPPER('PL & BS Leadsheets'!A5))>64,CODE(UPPER('PL & BS Leadsheets'!A5))<91),'PL & BS Leadsheets'!A5,0)

The range in sheet 'PL & BS Leadsheets' looks like this in column A (this is just a snip because it won't let me copy images onto here)

1V.01 Revenue - Sale of Goods
24-1020
34-1030
44-1060
54-1070
64-8400
7
8V.02 Revenue - Rent received
94-8450
104-8460
114-8500
12
13V.04 Revenue Handling commission received
144-8030
154-8040
164-8045
174-8047
184-8095
19

<tbody>
</tbody>



<colgroup><col></colgroup><tbody>
</tbody>




























However, the PROBLEM is that I will have 0's returned whenever that formula returns FALSE when it encounters the cells that don't start with a letter (i.e. the rest of the cells with a code which there is more of hence filling my worksheet with more 0 values than what I actually want returned (to see) which is the category headers (i.e. those starting with a letter).

My question: Is there a way to loop through that range in column A to skip through and check the next row (i.e. 'PL & BS Leadsheets'!A6, then 'PL & BS Leadsheets'!A7, and so on) when the formula returns a false instead of displaying a 0 each time? I understand this might take vba which I am fine with.

I am not great with vba but I am thinking possibly there could be a macro function added to the formula in place of 0 (e.g. nextrow()), then in the module of vba, the code to loop through my range.

i.e. =IF(AND(CODE(UPPER('PL & BS Leadsheets'!A5))>64,CODE(UPPER('PL & BS Leadsheets'!A5))<91),'PL & BS Leadsheets'!A5,nextrow())
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I tried this formula from this thread - https://www.mrexcel.com/forum/excel...nt-false-check-next-row-true-condition-2.html

=IFERROR(INDEX('PL & BS Leadsheets'!A$5:A$191,SMALL(IF(AND(CODE(UPPER('PL & BS Leadsheets'!A$5))>64,CODE(UPPER('PL & BS Leadsheets'!A$5))<91),ROW('PL & BS Leadsheets'!A$5:A$191)-ROW('PL & BS Leadsheets'!A$5)+1),ROW('PL & BS Leadsheets'!A1))),"")

It was close but did not work exactly like it was supposed to. Was giving blanks whenever the argument gave a false
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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
Back
Top