Getting hash instead the actual value from excel in PowerShell - excel

I want to get data from a column in excel sheet. In my case it's the 3rd one. I use a for loop in order to scan all the cells and I have the following column :
1,724.87
1,560.00
18,109.61
64.37
4,898.22
1,784.47
43,430.30
When I use the WorkSheet.Cells.Item($x,3).Text function in the loop to get the content of each cell, I get the following :
1,724.87
1,560.00
#######
64.37
4,898.22
1,784.47
#######
The ####### can be seen in the .xls file when I open it in excel. When I expand the width of the column it shows the actual number again. So I assume that it reads it as it is. What can be done in order to get the actual number?

It seems that the issue with WorkSheet.Cells.Item($x,3).Text is that .Text will represent anything shown on the screen in the cell. In my case is #######
To show the actual value of the cell ,should be using WorkSheet.Cells.Item($x,3).Value2. More difference between .Value, .Value2 and .Text can be found in this post :
What is the difference between .text, .value, and .value2?

Related

Excel If statement needs to show blanks while being nested

I am writing a formula to see cells that are blank along with see the cells that have a numeric value such as 0,10,-100 etc.
I have the following code that works but if the cell is blank it shows "0" and I need that to show blank. I should note that I am using offsets to make it easier to duplicate the data into other rows and just use REPLACE to speed up the process.
=IF(B1=DATEVALUE("7/3/2020"),OFFSET('CEDAR RAPIDS'!R4,0,0),
IF(B1=DATEVALUE("7/10/2020"),OFFSET('CEDAR RAPIDS'!R25,0,0),
IF(B1=DATEVALUE("7/17/2020"),OFFSET('CEDAR RAPIDS'!R47,0,0),
IF(B1=DATEVALUE("7/24/2020"),OFFSET('CEDAR RAPIDS'!R69,0,0),
IF(B1=DATEVALUE("7/31/2020"),OFFSET('CEDAR RAPIDS'!R91,0,0),
IF(B1=DATEVALUE("8/7/2020"),OFFSET('CEDAR RAPIDS'!R112,0,0),
IF(B1=DATEVALUE("8/14/2020"),OFFSET('CEDAR RAPIDS'!R133,0,0),
IF(B1=DATEVALUE("8/21/2020"),OFFSET('CEDAR RAPIDS'!R154,0,0),
IF(B1=DATEVALUE("8/28/2020"),OFFSET('CEDAR RAPIDS'!R174,0,0),
IF(B1=DATEVALUE("9/4/2020"),OFFSET('CEDAR RAPIDS'!R195,0,0),
IF(B1=DATEVALUE("9/11/2020"),OFFSET('CEDAR RAPIDS'!R215,0,0),
IF(B1=DATEVALUE("9/18/2020"),OFFSET('CEDAR RAPIDS'!R235,0,0),
IF(B1=DATEVALUE("9/25/2020"),OFFSET('CEDAR RAPIDS'!R255,0,0),
IF(B1=DATEVALUE("10/02/2020"),OFFSET('CEDAR RAPIDS'!R275,0,0),
IF(B1=DATEVALUE("10/9/2020"),OFFSET('CEDAR RAPIDS'!R295,0,0),
IF(B1=DATEVALUE("10/16/2020"),OFFSET('CEDAR RAPIDS'!R314,0,0),
IF(B1=DATEVALUE("10/23/2020"),OFFSET('CEDAR RAPIDS'!R334,0,0),
IF(B1=DATEVALUE("10/30/2020"),OFFSET('CEDAR RAPIDS'!R354,0,0),
IF(B1=DATEVALUE("11/6/2020"),OFFSET('CEDAR RAPIDS'!R374,0,0),
IF(B1=DATEVALUE("11/13/2020"),OFFSET('CEDAR RAPIDS'!R394,0,0),
IF(B1=DATEVALUE("11/20/2020"),OFFSET('CEDAR RAPIDS'!R414,0,0),
IF(B1=DATEVALUE("11/27/2020"),OFFSET('CEDAR RAPIDS'!R434,0,0),
IF(B1=DATEVALUE("12/4/2020"),OFFSET('CEDAR RAPIDS'!R454,0,0),
IF(B1=DATEVALUE("12/11/2020"),OFFSET('CEDAR RAPIDS'!R474,0,0)))))))))))))))))))))))))
I found this code below works correctly but I cannot seem to nest it like the above without errors.
=IF(B1=DATEVALUE("7/3/2020"),IF(ISBLANK('CEDAR RAPIDS'!F4),"",OFFSET('CEDAR RAPIDS'!F4,0,0)))
Format the result of the cells with a custom number format that suppresses zeroes, for example
0;-0;;#
By the way, if you want to check if the result of the OFFSET() is zero, then you need to check the result of the OFFSET(), not the anchor of the OFFSET().
There is bound to be a better formula for this scenario than this nested monster with Offset. Just ask.

Nesting error in Excel Formula - Changes to If

I'm currently trying to record a macro for my excel spreadsheet, but keep recieving the message "The specified formula cannot be entered because it uses more levels of nesting than are allowed in the current file format can anyone help me out in fixing the formula to make it smaller?
=IF(ISNUMBER(SEARCH("Conductor + Surface",B3)),"Conductor + Surface",IF(OR(ISNUMBER(SEARCH("17
1/2",B3)),ISNUMBER(SEARCH("Drilling",B3)),ISNUMBER(SEARCH("12 1/4",B3)),ISNUMBER(SEARCH("8
1/2",B3)),ISNUMBER(SEARCH("Run Screens",B3)),ISNUMBER(SEARCH("Temporay",B3)),ISNUMBER(SEARCH("BOP
Hop",B3)),(ISNUMBER(SEARCH("Data Acquisition",B3)))),"Inter, Res, Lower Comp., &
TP&A",IF(ISNUMBER(SEARCH("Maintenance",B3)),"BOP Maintenance",IF(OR(ISNUMBER(SEARCH("Re-
entry",B3)),ISNUMBER(SEARCH("Wellbore Prep",B3)),ISNUMBER(SEARCH("Run
Completion",B3)),ISNUMBER(SEARCH("Install TH",B3)),ISNUMBER(SEARCH("BOP
Pull",B3)),ISNUMBER(SEARCH("Subsea Move Off",B3)),ISNUMBER(SEARCH("BOP Run -
Completion",B3))),"Upper Comp & TH",IF(ISNUMBER(SEARCH("Rig Move - N and C",B3)),"Rig Move - N and
C",IF(ISNUMBER(SEARCH("Install XMT",B3)),"Install XMT w/ Rig",IF(ISNUMBER(SEARCH("Open
Plugs",B3)),"Open Plugs",IF(ISNUMBER(SEARCH("Rig Move - S and B",B3)),"Rig Move - S and
B",IF(ISNUMBER(SEARCH("Install VXT",B3)),"Install VXT","ERROR IN EXCEL FORMULA")))))))))
Currently there is a column with tasks that are too in depth, aka "New Conductor + Surface" or "ADCO - DG2 8 1/2" I want to make a new column with shorter names for each of them depending on certain words that are in the detailed column. I would then like to return an error if there is a detailed task that is not described properly.
This can be done by modifying the setup in this link to a 2 column lookup table.
See below for sample:
Array formula is =IFERROR(INDEX(lookupList,MATCH(TRUE,ISNUMBER(SEARCH(list,D7)),0),2),"NOT FOUND")
remember to press Ctrl+Shift+Enter when exiting cell edit mode.

Excel formula to calculate values based on other cells

I've got the following table:
I'm using the following formula in column F to get the sum of the values in column E: =SUMIFS(E:E,C:C,LEFT(TRIM(RIGHT([#[Object Name]],LEN([#[Object Name]])-FIND("=",[#[Object Name]]))),4),A:A,INT([#[Result Time]])) but it doesn't seem to work.
Evaluating the formula gives me the following result:
Can someone please take a took at the for
You are looking for an object name of "T054", when they all appear to be "CELL=T054CID"... so no results are being returned.
What exactly is it you are trying to do?
Is there any reason you cannot just do:
=SUMIFS([3G_Traffic_CS],[Object Name],[#[Object Name]],[Result Time],[#[Result Time]])
You will also notice that I am referencing just the column cells within the table, rather than the entire column. This is more efficient and will prevent any extra values which appear under the table being counted (unlikely but not impossible).
ALTERNATIVE (Using a Helper Column)
Add a helper column which contains a trimmed value of the Object Name and compare to that:
=SUMIFS([3G_Traffic_CS],[Trimmed Object Name],[#[Trimmed Object Name]],[Result Time],[#[Result Time]])
ANOTHER ALTERNATIVE (Using FIND and SUMPRODUCT)
If you want to include any Object Name which CONTAINS your trimmed value, you can do this using the FINDfunction with SUMPRODUCT:
=SUMPRODUCT(
([Result Time]=[#[Result Time]])*
(ISNUMBER(
FIND(LEFT(TRIM(RIGHT([#[Object Name]],LEN([#[Object Name]])-FIND("=",[#[Object Name]]))),4),
[Object Name]
)
))*
[3G_Traffic_CS]
)
YET ANOTHER ALTERNATIVE (Using a Wildcard as per #Jvdv's comment)
Again, this assumes that you want to include all Object Names which CONTAIN your trimmed site ID. Simply add a "*" to the start and end of your trimmed Object Name.
=SUMIFS([3G_Traffic_CS],
[Object Name],
CONCAT("*",
LEFT(TRIM(RIGHT([#[Object Name]],LEN([#[Object Name]])-FIND("=",[#[Object Name]]))),4),
"*"
),
[Result Time],
INT([#[Result Time]])
)

Change text to specific date format + Excel VBA

I want to change so many dates saved as text in excel sheets to Arabic (Hijri) date format, ie; dd/mm/yyyy to (right to left) yyyy/mm/dd .. it can be done manually be change custom format from Number Format panel ( by choosing the location , calendar type and the right format from list ) then replace the text in cell by same value ..
I need VBA code to automate this replacement process for any ltr date and for existing rtl date just convert the format from general to date ..
another problem , there is some other text around the date in cell like ( dd/mm/yyyy ttt ) . I want the code to remove this text (ttt) ( any text ) and then change to the right format
I found this code but it is not work to my specific need
Changing the date format to yyyy-mm-dd
I appreciate any help , thanks in advance ..
You have a number of separate problems and it is unrealistic to expect someone else to have posted a complete solution to that set of problems or that someone will code a complete solution for you. You need to split your total problem into its components and create or look for a solution to each component.
You have strings that contain CE dates in the format “dd/mm/yyyy”. These dates could be surrounded by text. You give the example “dd/mm/yyyy ttt”. Can ttt contain spaces? Could the “ttt” come before the date? Could the string be as complicated as “aaaa bbbb cccc 12/11/2016 dddd eeee ffff”?
Whatever the situation, I suspect something like:
Dim Part() As String
Part = Split(.Cells(R, C).Value," ")
would be the core of first step. With my complicated example, this would give:
Part(0) = "aaaa"
Part(1) = "bbbb"
Part(2) = "cccc"
Part(3) = "12/11/2016"
: : : :
A loop over the parts of each cell value looking for a string for which IsDate gives True would allow you to find the date so .Cells(R, C).Value = Part(N) would delete the unwanted text.
I would take a copy of your data and try to code a macro that discards the unwanted text. If you can successfully create that macro, you have completed step 1 of your solution. If you have trouble with this macro, you can ask for help here and expect to get it.
The next step is to convert the string “dd/mm/yyyy” to an Excel date. Excel holds dates as the number of dates since 1/1/1900 CE. Replacing:
.Cells(R, C).Value = Part(N)by .Cells(R, C).Value = CDate(Part(N))ought to do the trick. However, Excel sometimes tries to interpret “dd/mm/yyyy” dates as “mm/dd/yyyy”. I think you will be alright but be aware of this possibility.
Your last step is to convert a date from the CE calendar to the Hijri calendar. This is not just a format issue. The two calendars have different year zeroes and different month lengths. There may be a standard conversion function in your country but there does not appear to be one here in the UK. There is help online so you should be able to find a function that will perform the conversion.
You have a number of separate problems and it is unrealistic to expect someone else to have posted a complete solution to that set of problems or that someone will code a complete solution for you. You need to split your total problem into its components and create or look for a solution to each component.
You have strings that contain CE dates in the format “dd/mm/yyyy”. These dates could be surrounded by text. You give the example “dd/mm/yyyy ttt”. Can ttt contain spaces? Could the “ttt” come before the date? Could the string be as complicated as “aaaa bbbb cccc 12/11/2016 dddd eeee ffff”?
Whatever the situation, I suspect something like:
Dim Part() As String
Part = Split(.Cells(R, C).Value," ")
would be the core of first step. With my complicated example, this would give:
Part(0) = "aaaa"
Part(1) = "bbbb"
Part(2) = "cccc"
Part(3) = "12/11/2016"
: : : :
A loop over the parts of each cell value looking for a string for which IsDate gives True would allow you to find the date so .Cells(R, C).Value = Part(N) would delete the unwanted text.
I would take a copy of your data and try to code a macro that discards the unwanted text. If you can successfully create that macro, you have completed step 1 of your solution. If you have trouble with this macro, you can ask for help here and expect to get it.
The next step is to convert the string “dd/mm/yyyy” to an Excel date. Excel holds dates as the number of dates since 1/1/1900 CE. Replacing:
.Cells(R, C).Value = Part(N)by .Cells(R, C).Value = CDate(Part(N))ought to do the trick. However, Excel sometimes tries to interpret “dd/mm/yyyy” dates as “mm/dd/yyyy”. I think you will be alright but be aware of this possibility.
Your last step is to convert a date from the CE calendar to the Hijri calendar. This is not just a format issue. The two calendars have different year zeroes and different month lengths. There may be a standard conversion function in your country but there does not appear to be one here in the UK. There is help online so you should be able to find a function that will perform the conversion.
You have a number of separate problems and it is unrealistic to expect someone else to have posted a complete solution to that set of problems or that someone will code a complete solution for you. You need to split your total problem into its components and create or look for a solution to each component.
You have strings that contain CE dates in the format “dd/mm/yyyy”. These dates could be surrounded by text. You give the example “dd/mm/yyyy ttt”. Can ttt contain spaces? Could the “ttt” come before the date? Could the string be as complicated as “aaaa bbbb cccc 12/11/2016 dddd eeee ffff”?
Whatever the situation, I suspect something like:
Dim Part() As String
Part = Split(.Cells(R, C).Value," ")
would be the core of first step. With my complicated example, this would give:
Part(0) = "aaaa"
Part(1) = "bbbb"
Part(2) = "cccc"
Part(3) = "12/11/2016"
: : : :
A loop over the parts of each cell value looking for a string for which IsDate gives True would allow you to find the date so .Cells(R, C).Value = Part(N) would delete the unwanted text.
I would take a copy of your data and try to code a macro that discards the unwanted text. If you can successfully create that macro, you have completed step 1 of your solution. If you have trouble with this macro, you can ask for help here and expect to get it.
The next step is to convert the string “dd/mm/yyyy” to an Excel date. Excel holds dates as the number of dates since 1/1/1900 CE. Replacing:
.Cells(R, C).Value = Part(N)by .Cells(R, C).Value = CDate(Part(N))ought to do the trick. However, Excel sometimes tries to interpret “dd/mm/yyyy” dates as “mm/dd/yyyy”. I think you will be alright but be aware of this possibility.
Your last step is to convert a date from the CE calendar to the Hijri calendar. This is not just a format issue. The two calendars have different year zeroes and different month lengths. There may be a standard conversion function in your country but there does not appear to be one here in the UK. There is help online so you should be able to find a function that will perform the conversion.

SSRS Export to CSV Error

I have an SSRS report that has a column in it that when exported to Excel (XLSX) displays properly, but when exported to CSV, it gives an error that I can't seem to figure out how to fix.
The column value is the following expression (sorry for the formatting, SSRS makes it difficult to format this into an easily readable statement):
=IIF(IsNothing(Fields!SomeField1.Value) Or Fields!SomeField1.Value = "",
"",
(Replace("- " + Fields!SomeField1.Value,
",",
vbCrLf + "-")))
+ IIF(IsNothing(Fields!SomeField2.Value) Or Fields!SomeField2.Value = "",
"",
vbCrLf + "- " + Fields!SomeField2.Value)
The error displayed in the CSV file is:
The value in the CSV's formula bar shows =- N/A. The - seems to be what causes the error but I can't figure out why. This behavior is especially strange because there are other rows with values in the same column like - Test comment and - Yet another testing comment that display without any errors...
The - character is required because the business wants the column to display as a bulleted list. Is there any way to fix this without removing the -?
You can prefix the cell value with an apostrophe (the ' character) to tell Excel that the value you are entering into the cell is to be treated as text rather than a formula and should be displayed as-is.
Sorry don't have rep to comment but you can just add an extra IIF statement around your code block using Globals!RenderFormat = "CSV" to add formatting to the expression for that field. It shouldn't require an extra function (unless this is required for more than just the one field)

Resources