I need to get CPT codes (f2,f3,f4,f5,f6,f7) and Amount(K2,k3,k4.k5.k6.k7)belong to per claim number(B2) and will save into a string variable with Table format for CPT codes and amount . It may vary per claim numbers
I need to read the values CPT and Amount from the excel sheet by claim number then store into a string variable.
My Expected output is
String Reason :
CPT Amount
1
2 125
3
4 67
There is a Similar post created by you where we did have the solution received, we could use the same start logic here as well, but here instead of the Array of Strings it is the Table Format that you would require. The post mentioned :
The same logic can be used but the conversion should be to a Datatable.
For that we could change the Linq Expression to the below :
Here, filteredRowsCount is a variable to type Integer. We fetch the Total rows from the next position of the row Index of the value found to the next non-empty value. This count is used to retrieve the Filtered/Required rows later.
We could take the Required number of rows since we now have the rowIndex and the number of rows the value found is mapped in the below way :
Next, in order for the Formatting to be properly made look as a Table, we would need to fetch the count/Length of the Largest word in the Whole Filtered Table (including column Names). For that we could do the following operations :
Here, the variables columnNamesLongestValueLength, rowValuesLongestLength and LongestLengthValue are of integer type.
Next, we perform the formatting based on the LongestLengthValue and use PadRight for appending the remaining spaces required for the word, hence preserving a table like look.
Maybe a better approach could be used for this task, but when considering the formatting for a Generic data I did arrive at this conclusion.
Let us know if this doesn’t work or if you are facing any issues.
Also, we see that there are multiple threads created by you which may ultimately ask the same question as this thread. Do make sure to close them if you requirements are met, thus avoiding duplicate topics.
To Also handle scenarios, where the input value to search doesn’t exist in the excel data, we could also maybe perform a Check on the rowIndex to check if it is greater than -1, then only perform the remaining Steps.