Condidional output a few cells from adjacent сolumns

Hi

There is 2 columns in Excel worksheet - "Invoices" and "Value". I need to output only the cells in column "Invoices"  which corresponding  "Values" ​​are blank cells. I am attaching  the explanatory image. The result should look like this :
                               1815
                               2014
                              18013
                              22018
                              16014
                              15255

Any help appreciated
Ivoices.gif
nesher13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MontoyaProcess Improvement MgrCommented:
try the ISBLANK function

=IF(ISBLANK(B4),A4) ... substitute B4 for your value column and A4 for your invoice column. Copy to all cels below.

Let me know if you have any other questions
0
NBVCCommented:
If you are trying to output a separate list elsewhere in the sheet, then try:

=IFERROR(INDEX($G$3:$G$12,SMALL(IF($H$3:$H$12="",ROW($H$3:$H$3)-ROW($H$3)+1),ROWS($H$3:$H3))),"")

confirmed with CTRL+SHIFT+ENTER not just ENTER, then copy down.
0
nesher13Author Commented:
Iammontoya

I have no problem to write operator "if" "else".
My problem is that I'm confused with the loops "For"  or "Foreach"
I also can not refer to the adjacent  column or the adjacent cell  with structure offset.
0
Hey MSSPs! What's your total cost of ownership?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

Prashant GirennavarCommented:
if you like to use powershell below is the code.

Please convert your excel to csv  and run it

$Line = @()
import-csv C:\input.csv | %{
if($_.Value -eq "$null")
{
$line+= $_.name
}
}

$line | out-file C:\Formattedoutput.csv

Open in new window


let me know if you need more help

Thanks,

-Prashant Girennavar.
0
nesher13Author Commented:
NBVC

If you are trying to output a separate list elsewhere in the sheet
I am not. I now no matter where in Excel to store selected invoices numbers.  Likely they will be piped out
0
MontoyaProcess Improvement MgrCommented:
Hey there,

Sorry about that. I did not see anything about you trying to use For/Next loops. Perhaps there's a requirement here I did not get from the post?

Perhaps if you can give me more specific information?

Thanks!
0
nesher13Author Commented:
Iammontoya

This my code:
$ExcelPath = "c:\users\user1\documents\Template.xlsx"


$Excel = New-Object -ComObject "Excel.Application"
$Workbooks = $Excel.Workbooks
$Workbook = $Workbooks.Open($ExcelPath)
$Worksheets = $Workbook.Worksheets
$Sheet1 = $Worksheets.Item(1) | Where {$_.name -eq "sheet1".select}
$Range = ("H3:H12")
$Rows = $Range.Rows



For ($k = 3; $k -le $Range; $k = $k + 1){

If ($Value -ne "") and ($Value -ne $null) {"no-blank value in row $k"}
   
      Else {"blank value in row"}
}}

$result | Where {!$_.Values} | Foreach {$_.Invoices}

$Excel.Quit()
0
nesher13Author Commented:
PrashantGirennavar

Please convert your excel to csv  and run it
I am save the excel.xlsx file as .csv (coma delimeted)
when script is running I am receive message:
WARNING: One or more headers were not specified. Default names starting with "H" have been used in place of any missing headers.

What am I doing wrong?
0
NBVCCommented:
I am not sure what your comment to me means.  Can you elaborate?

My formula will "copy" over the invoices that have no values to whereever you put the formula in.
0
Prashant GirennavarCommented:
Hello,

 I think , you are not saving Csv file properly with the headers.

Follow below steps , Open a excel and put the value like below

screen1save the excel as csv like below.

screen2
post that , run the script.

Make sure to change the path in the script accordingly

Let me know if this does not work.

Thanks,

-Prashant Girennavar.
0
nesher13Author Commented:
Hi folks,

unfortunately none of the answers does not lead to the desired result
0
Prashant GirennavarCommented:
Did you try the script which is provided by me?

If yes what is the output? Are you getting any error message while executing it.

When I run the script here. it works fine.

Let me know where you are stuck.

Thanks,

-Prashant Girennavar.
0
nesher13Author Commented:
Solution is as follows:


Open in new window

$ex = New-Object -ComObject Excel.Application
$ex.Visible = 1
$wb = $ex.Workbooks.Open("C:\users\dov143\Documents\Template.xlsx")
$ws = $wb.Worksheets.Item(1)

$result = @()

[int]$rmax = $ws.Range("G65536").End(-4162).Row
$ws.Range("G3:G$rmax") | Where {$_.Value2} | Foreach {
      $col = $_.Column+1
      $row = $_.Row
      $val = $ws.Cells.Item($row,$col)
      
      $result += [pscustomobject]@{
            Invoices = $_.Value2
            Values = $val.Value2
      }
}
      
$result | Where {!$_.Values} | Foreach {$_.Invoices}

$ex.Quit()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.