How do i remove blank lines from code filled list - excel-formula

I have a problem and have modified “jlore” code of =if(d3 = "PS588", c3, "")
which works, but is there a way to populate so I don't get blank lines? My task is to generate an Excel HV switching program on one sheet then on the next an isolation list. I am attempting to auto populate the Isolation list with the code =IF(HVSP!H30 = "APPLY ISOL LOCK & TAG", HVSP!E30, "").
However as stated if the "APPLY ISOL LOCK &TAG" isn't in the cell my isolation list creates a blank line.
Regards
Steve Mack

If i have understood your question correctly, you are getting a blank cell because of the ,"") at the end. If you change this to ,"DON'T APPLY ISOL LOCK & TAG") or wording of your choice you will not get a blank cell.
Hope this helps.

Related

Setting Cell Value as Formula

Could someone tell me what I am doing wrong with this sytax?
Worksheets("LTXN Report").Range("A2").Formula = "=""####-#""&IF(Launch!C7<>,RIGHT(Launch!,LEN(Launch!C7)-5),IF(Launch!C15<>,RIGHT(Launch!C15<>,LEN(Launch!C15)-5),IF(Launch!C23<>,RIGHT(Launch!C23,LEN(Launch!C23)-5),)))"
Essentially what I am doing is setting a clear function that copies a back up version of my sheets and replaces the previous version. However, on my launch worksheet, there are three options to search by (represented by cells C7, C15, and C23). The spreadsheet will pull transaction data and then filter it into a report, and I am trying to have this formula be filled out in the A2 cell of the new report when the new page is created.
I keep getting an object error. It seems like it doesnt like me using #'s or *'s to mask the account number in the function. Any ideas on how I could still do this?
I got it here. I simply had the quotes incorrect.
Worksheets("LTXN Report").Range("A2").Formula = "=""****-*""&IF(Launch!C7 <> """",RIGHT(Launch!C7,LEN(Launch!C7)-5),IF(Launch!C15 <> """",RIGHT(Launch!C15,LEN(Launch!C15)-5),IF(Launch!C23 <> """",RIGHT(Launch!C23,LEN(Launch!C23)-5),"""")))"
works!

How to add running count to excel cell, which already has text in it?

Would anyone have advise on how to add running count to excel cells, which already have text in them, and without removing the said text.
Few screenshots will follow to clarify my issue.
I have received a ton of sheets which have a test case name as a text/string in the C column and they are missing a running count from the beginning of the cell (not sure if the "running count" is the correct term).
In the first screenshot you can see how I need them to be, as well as in the couple first rows of the second screenshot (column C). So the original text could be for example "Purchase order" and I want it to be "1. Purchase order" and the next cell would be "2. Purchase order" etc.
Screenshot 1.
Screenshot 2.
I imagine there isn't an already existing function in excel which would solve my problem. I have played around with macros and VBA some years ago, but don't have any clue from on top of my head how to solve this.
Perhaps a macro that would go through each cell from the selected column one by one, cut the existing text, add a variable number to the cell and then copy the cut text back there after the variable, then add +1 to the variable before moving to the next cell?
So I somewhat understand the logic how it could be done, but don't have any memory how the syntax and the operators etc. work in VBA.
Thank you in advance.
Not exactly sure what you want from the images, but you can do things like this:
If cell A1 has 942
and cell B1 has "slices of bread"
Then C1 can have the result "942 slices of bread":
=A1&" "&B1
Not sure neither if running count is the right term, but you can do it with a helper column and an easy formula:
=COUNTIF($C$2:C2;C2)&". "&C2
Then you can copy/paste as values and delete helper column

Inserted formula with cell reference does not recognize new input

I swear this just worked yesterday...
I have a program that creates formulas within certain cells that depend on subsequent data entries into other cells:
Cells(i, 40).Formula = "= (N" & i & ")/AP" & i
So, APi can be input and/or changed after the fact, and the formula should give you the result for whatever value is there. However, I get a #Div/0! error no matter what value is in that cell. When I evaluate the formula (within Excel) and step through the calculations, it shows this (for one particular cell):
= (N64)/AP64 = (47.35)/AP64 = 47.35/AP64 = 47.35/9 = #DIV/0!
So, the formula recognizes that there is a value in the cell AP64, but then does not use it to properly calculate the result.
As I said at the top, this worked as I expected yesterday afternoon when I was testing it. Now that I need other people to start using it, of course, it doesn't. I changed nothing within the program relative to these lines of code.
I apologize if this is answered elsewhere - I really have no idea how to create a search for this type of problem.
Two things to check:
1) Value of the cells used is formatted to a number (i've had #Value based on that a couple times) and
2) verify that modifying the code using fixed references provides the appropriate output ("A16" for some reason wasn't recognized as a cell reference in one I had show up). E.g., "$N" & i & "/$AP" & i
If those both look alright, you might try something like:
.Range(.Cells(3,40),.Cells(lr,40)).Formula = "=$N3/$AP3" 'ensure no random spaces
This should act like a fill-down in which the # 3 is iterated with the same row as the formula.

How do I reference an Excel ListObject table column if the column name has line breaks?

I'm tasked with the following:
several sheets from different workbooks have to be copied to a new workbook
each of those sheets contains an Excel table (a ListObject), named like the sheet with a postfixed T (sheet Foo, table: FooT)
the new workbook has to contain a summary sheet where each table name is listed, and various values of the respective tables are presented by referencing them with suitable formulas
This has to be done frequently for different workbooks, so the idea was to do this in VBA.
Copying the sheets is easy, listing the table names in a new sheet is easy, but referencing the values runs into problems.
The general idea is to do the following
ActiveSheet.Range("A1").Value = "FooT"
ActiveSheet.Range("B1").Formula = "=FooT[[#Totals],[Quantity]]"
ActiveSheet.Range("C1").Formula = "=FooT[[#Totals],[Total List Price]]"
and iterate over all sheets.
Setting the value for A and the formula for B works as expected and gets the expected results.
The issue with C is that instead of "Total List Price", the column header is actually formatted as
"Total
List
Price"
I can't change that, this has been a design decision.
This is also how the column name shows up in the formula if I add the formula to the cell manually.
So there's some sort of line break happening here, and I've tried cater to this in VBA with
ActiveSheet.Range("C1").Formula = "=FooT[[#Totals],[Total" & vbCrLf & _
"List" & vbCrLf & _
"Price]]"
and vb_Cr and vb_Lf and vb_Newline instead of the vbCrLf. Trying to set C's formula to any of these variations yields the infamous Error 1004.
Getting the value of the column header from one of the sheets and using it in the formula works. This could be a potential workaround, but I'd really like to know what I'm missing or how I can figure out how to build this formula string correctly.
Your formula is OK but typically, the newline character will be vbLf if the title was set from the keyboard. I also suspect there might be leading and/or trailing space characters anywhere in the title. Select your title cell and, from the VBE's Immediate Window (Ctrl+G), type Debug.Print ActiveCell.Value, then check where each printed line ends.
Are you using Option Explicit? In your question, you mention you've tried vb_Lf but this constant doesn't exist and, without Option Explicit, would have been interpreted as an empty string.
When you enter a line break in a cell, the text is actually continuous to the previous line, there being no separator character, unless you enter a space before the break. To name the column you must write it without a space between the last word of the previous line and the first of the next, like this: [TotalListPrice]

Excel - Summarize in text

In the spreadsheet below, I have no problem summing the numbers. What I need, however, is a string which I can input into our time recording system (so I can just cut and paste it over). I want to ignore descriptions for buckets which have no time allocated on that day. The bottom row in the image is an example of what I need, but how can I get this to happen automatically in Excel? (assuming that the range having the data in will always be B3:F8)
Here is the formula you can try:
=IF(B3="","",$H3&" ("&B3&"hrs)")&IF(B4="","",CHAR(10)&$H4&" ("&B4&"hrs)")&IF(B5="","",CHAR(10)&$H5&" ("&B5&"hrs)")&IF(B6="","",CHAR(10)&$H6&" ("&B6&"hrs)")&IF(B7="","",CHAR(10)&$H7&" ("&B7&"hrs)")&IF(B8="","",CHAR(10)&$H8&" ("&B8&"hrs)")
I heard there is a TEXTJOIN funciton in Excel 2016 that can do the same work quickly but unfortunately I don't have it with me. But anyway, try this formula and let me know.
Is it ok to have gaps in the rows for unused buckets? If so, then assuming your first data row is row 3, something like =IF (B3>0, $H3 & "(" & B3 & " hrs)", "") and copy that to all your "summary" cells (though there's no actual summing taking place). If not, then the only way I can think of involves VBA code...

Resources