Link to home
Start Free TrialLog in
Avatar of nesher13
nesher13Flag for Israel

asked on

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
Avatar of Montoya
Montoya

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
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.
Avatar of nesher13

ASKER

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.
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.
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
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!
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()
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?
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.
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

User generated imagesave the excel as csv like below.

User generated image
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.
Hi folks,

unfortunately none of the answers does not lead to the desired result
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.
ASKER CERTIFIED SOLUTION
Avatar of nesher13
nesher13
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.