if {spFMGenerateSubReportB;1.BendNo} > 0 then
(totext({spFMGenerateSubReportB;1.SheetTotal} * {spFMGenerateSubReportB;1.BendNo}, 0) )
else
""
When i saved this formula in crystal report. It says a string is required here.
Does anyone know how to solve it
I would suspect either {spFMGenerateSubReportB;1.SheetTotal} or {spFMGenerateSubReportB;1.BendNo} are non-numeric fields. Probably contains a alpha or punctuation mark somewhere in the field. This formula should help you vet that out if it is the case
if isnumeric({spFMGenerateSubReportB;1.SheetTotal}) and isnumeric({spFMGenerateSubReportB;1.BendNo}) then
if tonumber({spFMGenerateSubReportB;1.SheetTotal})>0 then
(totext(tonumber({spFMGenerateSubReportB;1.SheetTotal})*tonumber({spFMGenerateSubReportB;1.BendNo}),0) )
else ""
else "NonNumeric"
Related
i think i have a syntax problem.
I just want to check with vba if theres every field filled for next steps.
I need like 15 more cells to check
Maybe someone can help me
my code work, just the first line give error because of this "and ("C24:C22")"
For Each Zellen_auf_Inhalt_prüfen In Range("B7:J7") **and ("C24:C22")**
If Zellen_auf_Inhalt_prüfen.Value = "" Then
MsgBox "Bitte alle Zellen ausfüllen."
GoTo MacroEnde
End If
Next Zellen_auf_Inhalt_prüfen
"Zellen auf inhalt prüfen" means, to check cells if theres anything in
i google but i dont find any solution.
I think you are looking for the union statement:
For Each Zellen_auf_Inhalt_prüfen In Union(Range("B7:J7"), Range("C24:C22"))
I have created a spreadsheet with VBA functions in a PT-BR (comma as decimal) Excel. Everything works fine.
But a client (running it on EN-US) had a weird issue: decimal numbers, such as 3.88888 were copied as hole numbers, like 388888. Numbers with less decimal cases, like 2.5, get copied as 2,5, and not recognized as numbers.
My function is just copying the value, like this:
ResultsSheet.Cells(row, 3).Value=DataSheet.Cells(row, 11).value
Unfortunately, I am unable to reproduce this issue. On either language setting, I get correct results - which is what I would expect.
Anyone having experienced this, or pointing me to some information would be greatly appreciated. I would also help with clues on how to reproduce my client's issue.
As you said, quite tricky to recreate the problem, but type conversion with some checks should work, snippet below.
If InStr(DataSheet.Cells(Row, 11).Value, ",") > 0 Then
'check if text contains a comma, and if so replace with "."
ResultsSheet.Cells(Row, 3).Value = CDec(Replace(DataSheet.Cells(Row, 11).Text, ",", "."))
Else
If IsNumeric(Cells(r, 11).Value) Then
'check if numeric and ensure decimal value on ResultsSheet
ResultsSheet.Cells(Row, 3).Value = CDec(DataSheet.Cells(Row, 11).Text)
Else
'if text then just copy
ResultsSheet.Cells(Row, 3).Value = DataSheet.Cells(Row, 11).Value
End If
End If
Hope this solves your issue. Boa Sorte ^^.
Miguel
I have a GUIDE GUI where I ask the user to enter in their name. It should execute an error dialog if they enter numerical characters, a mix of string and numerical characters, or a blank box.
The issue is that when I enter in numbers or a mix of string and numerical characters, then it is outputting Error Code II (1st elseif statement) instead of Error Code III (entering in numbers only) or Error Code IV (entering numbers and strings). Input would be greatly appreciated.
Here's essentially what I have:
if isempty(editString)
errordlg('Please enter a name into the text-box. We thank you in anticipation.',...
'Error Code I');
return
elseif char(editString) > 12
errordlg('Please enter a name that is less than 12 characters long. Thank you.',...
'Error Code II');
return
elseif isa(editString, 'integer')
errordlg('Please enter a name, not numbers. Thank you.', 'Error Code III');
return
elseif isa(editString, 'integer') && isa(editString, 'char')
errordlg('Please enter a name without mixing numbers & characters. Thanks.',...
'Error Code IV');
else
delete(gcf)
gui_02
end
Well, isa() function doesn' t work in this case because all you read from Edit Text is string in other words char. Thus, if you even write isa('123', 'integer'), function returns 0 not 1. Anyway, thanks to MATLAB there is a function: isstrprop() determines whether string is of specified category such as integer, char..
Check the code below:
if isempty(editString)
errordlg('Please enter a name into the text-box. We thank you in anticipation.', 'Error Code I');
return
elseif length(editString) > 12
errordlg('Please enter a name that is less than 12 characters long. Thank you.', 'Error Code II');
return
elseif ~isempty(find(isstrprop(editString, 'digit'), 1)) & isempty(find(isstrprop(editString, 'alpha'), 1))
errordlg('Please enter a name, not numbers. Thank you.', 'Error Code III');
return
elseif ~isempty(find(isstrprop(editString, 'digit'), 1)) & ~isempty(find(isstrprop(editString, 'alpha'), 1))
errordlg('Please enter a name without mixing numbers & characters. Thanks.', 'Error Code IV');
return
end
It doesn' t look elegant but works.
I've got the value '9,2' (dutch notation of '9.2') within a cell of a .xlsx file, the cell has a 'general' number format. Also the value in the upper bar where you also view formulas says '9,2' When I read this cell with PHPExcel with ->getValue() I get '9,199999999999999'.
This is my code:
$oPhpReader = PHPExcel_IOFactory::createReader($sFileType);
$aWorksheetNames = $oPhpReader->listWorksheetNames($sFileName);
$oPhpReader->setReadDataOnly(true);
$oPhpReader->setLoadSheetsOnly($aWorksheetNames[0]);
$oPhpExcel = $oPhpReader->load($sFileName);
$oWorksheet = $oPhpExcel->getActiveSheet();
$oCell = $oWorksheet->getCellByColumnAndRow($iCol,$iRow);
$sTempValue = $oCell->getValue();
This is the way I solved my problem now. Though I do not think this is a very neat solution, it is probably the only way.
I just figured I will never get numbers with more than 12 digits, only when PHPExcel get them wrong. So I round all my floats to 12 digit using number_format:
if ((is_numeric($sTempValue))&&(strpos($sTempValue,'.')))
{
$sTempValue = rtrim(rtrim(number_format($sTempValue,12,',',''),'0'),',');
}
I have few cells where I fill date in those using 'FormatDatetime' function,
code:
Range("AX1") = FormatDateTime((Docx.getAttribute("r1ed")))
Range("AX2") = FormatDateTime((Docx.getAttribute("r2ed")))
Range("AX3") = FormatDateTime((Docx.getAttribute("r3ed")))
Range("AX4") = FormatDateTime((Docx.getAttribute("r4ed")))
If date is separated by "." all the cells would show like "12.1.2013",but if I change my system date format separated by "-","AX4" shows date as still "12.1.2013".but other shows correctly.
I need to have fix for this,since I use these dates' for calculation later in VBA.
Please suggest some answers.
I think your problem is that FormatDateTime() returns a string, change it to DateValue() instead. If the return from Docx.getAttribute() contains dots you'll need to replace them with slashes first.
So;
'[AX1] is the same as Range("AX1")
[AX1] = DateValue(Docx.getAttribute("r1ed"))
[AX2] = DateValue(Docx.getAttribute("r2ed"))
[AX3] = DateValue(Docx.getAttribute("r3ed"))
[AX4] = DateValue(Docx.getAttribute("r4ed"))
Or, if there are dots;
[AX1] = DateValue(Replace(Docx.getAttribute("r1ed"), ".", "/"))
[AX2] = DateValue(Replace(Docx.getAttribute("r2ed"), ".", "/"))
[AX3] = DateValue(Replace(Docx.getAttribute("r3ed"), ".", "/"))
[AX4] = DateValue(Replace(Docx.getAttribute("r4ed"), ".", "/"))
If this doesn't solve the issue, can you please post more info about what Docx.getAttribute() is returning please.
Edit: Also, knowing the format you need the cells to contain would be helpful - I'm assuming proper dates will be acceptable - You might need a string with a date in a certain format. If that's the case you could wrap the above with something like;
[AX1] = Format(DateValue(Docx.getAttribute("r1ed")), "dd/mm/yyyy")
It might be that FormatDateTime() is betraying you, Format() might be more flexible