If column has number then return string. If not then skip

PuntingJawa

Board Regular
Joined
Feb 25, 2021
Messages
140
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
If Column B has a specified number I would like to string together a series of cells into a Cell G through and H. If the value isn't there then I would like it to skip. However, I would like it to not skip cells.
Example.
=IF(B1=2,"TheirP/N "&D5&" Our P/N "&E5&" Serial # "&C5,"")
So, if B1 is equal to 2 then return "TheirP/N " and D5 value and " Our P/N " and E5 Value and "Serial# " and C5 Value.
This is what I have so far. What I am trying to do is make it to when I place this in G1 that it does not leave blank cells. Is this possible?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
It appears this should work. What problems or errors are you getting?
 
Upvote 0
It's not so much an error as it is that the list is 400 lines. #1 is in cell G and #2 in H. So the string bounces back and forth between the cells and makes it hard to print out.
I was hoping there was a way to formulate this where it placed all the data on the topmost cell in the column.

Example. If Cells B1 through B5 had #1 and B6 through B10 had #2 then G1 through G5 would show the data string for #1's data and H1 through H5 would show the data string of #2 without skipping cells. This is what I want it to do if it's possible.
Instead, with my formula as is, it currently places #1 data to G1 through G5 an #2's data from H6 through H10.
 
Upvote 0
Can you sort based on increasing numerical values in Column B? That should do what you are asking for if I understand the problem.
 
Upvote 0
Very true, I was just hoping to automate it by having it populate to another sheet.
 
Upvote 0
Assuming your data in on Sheet1 and you want the data on Sheet2, I think this should get you close:

Cell Formulas
RangeFormula
G2:G9G2=IF(B2=2,"TheirP/N "&D2&" Our P/N "&E2&" Serial # "&C2,"")
H2:H9H2=IF(B2=1,"TheirP/N "&D2&" Our P/N "&E2&" Serial # "&C2,"")


Book1
GH
2TheirP/N 13 Our P/N 18 Serial # 8TheirP/N 12 Our P/N 17 Serial # 7
3TheirP/N 15 Our P/N 20 Serial # 10TheirP/N 14 Our P/N 19 Serial # 9
4TheirP/N 16 Our P/N 21 Serial # 11TheirP/N 17 Our P/N 22 Serial # 12
5TheirP/N 18 Our P/N 23 Serial # 13TheirP/N 18 Our P/N 23 Serial # 13
6
Sheet2
Cell Formulas
RangeFormula
G2:H5G2=FILTER(Sheet1!G:G,Sheet1!G:G<>"")
Dynamic array formulas.


H2 has the formula =FILTER(Sheet1!H:H,Sheet1!H:H<>"")
(not sure why it didn't show up above)
 
Upvote 1
Solution
You could do it directly without the helper columns.

23 05 05.xlsm
BCDE
1
2171217
3281318
4191419
52101520
62111621
71121722
82131823
91131823
10
Sheet3


23 05 05.xlsm
GH
1
2TheirP/N 13 Our P/N 18 Serial # 8TheirP/N 12 Our P/N 17 Serial # 7
3TheirP/N 15 Our P/N 20 Serial # 10TheirP/N 14 Our P/N 19 Serial # 9
4TheirP/N 16 Our P/N 21 Serial # 11TheirP/N 17 Our P/N 22 Serial # 12
5TheirP/N 18 Our P/N 23 Serial # 13TheirP/N 18 Our P/N 23 Serial # 13
6
Sheet4
Cell Formulas
RangeFormula
G2:G5G2=FILTER("TheirP/N "&Sheet3!D2:D100&" Our P/N "&Sheet3!E2:E100&" Serial # "&Sheet3!C2:C100,Sheet3!B2:B100=2,"")
H2:H5H2=FILTER("TheirP/N "&Sheet3!D2:D100&" Our P/N "&Sheet3!E2:E100&" Serial # "&Sheet3!C2:C100,Sheet3!B2:B100=1,"")
Dynamic array formulas.
 
Upvote 1

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

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