In excel I am using Nested IF statement and not sure why I am getting "there is too many arguments in this function". Is it because there is an overlap in the statement?
The Nested IF statement is supposed to output one of the following choices: HazOp, SIL, LOPA, HazOp & SIL, HazOp & LOPA
=IF(AND(C42="HazOp"),"HazOp",IF(AND(C43="SIL"),"SIL"),IF(AND(C44="LOPA"),"LOPA",IF(AND(C42="HazOp",C43="SIL"),"HazOp & SIL",IF(AND(C42="HazOp",C44="LOPA"),"HazOp & LOPA",0))))
If you have Office 365 Excel use this:
=TEXTJOIN(" & ",TRUE,C42:C44)
If not use this:
=MID(IF(C42<>""," & " & C42,"") & IF(C43<>""," & " & C43,"") & IF(C44<>""," & " & C44,""),4,99)
Related
I am trying to make this code work in vba excel however i keep receiving Expected End error
URL_Last = "&entry.7170534=" & EmpID & "&entry.634952910=" & EmpName & "&entry.1900852350=" & Gender & "&entry.776101390=" & Designation & "&entry.1211978069=" & Address & "&submit=Submit"
Form_URL = URL_First & URL_Last
May i ask what adjustment should i do inorder to fix this? Thanks
This is probably a simple task, but for some reason I’m not quite getting it right.
I want to save a copy of the active workbook to a different file. I have used a code in the past to do this with the date, but I want to remove the date. The code I used in the past is the following:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products & Services\Investment Research & Communication\Structured Products\" &Format(dtdate) & " " & "Structured Product Tool" & " " & "Bloomberg" &".xlsm"
What I want is to remove the date, so the name will be: Structured Product Tool Bloomberg
I thought it would be the following:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products Services\Investment Research & Communication\Structured Products\"Structured Product Tool" & " " & "Bloomberg" & ".xlsm"
But I’m getting an error.
Does anyone know the correct code for this?
Thanks, Peter
You are missing an ampersand & in your statement:
ActiveWorkbook.SaveCopyAs "P:\Wealth Management Products & Services\Investment" _
& "Research & Communication\Structured Products\" _
& "Structured Product Tool" & " " & "Bloomberg" & ".xlsm"
on my excel sheet the user can choose some video clips and arrange in different order to play as a vlc playlist. Unfortunately it can’t be guaranteed that the video file names haven’t any blanks.
To build the vlc playlist I use successfully:
Dim PL
PL = Shell("C:\Program Files\VideoLAN\VLC\VLC.exe " & certainPath & "\Movie6.flv" & " " & certainPath & "\Movie7.flv" & " " & certainPath & "\Movie8.flv ", 1)
'using "\Movie 6.flv" 'doesn't work of course
'using "\'Movie 6.flv'" 'doesn't work aswell
Is there another way to encapsulate file name with blanks?
thankfull for a hint.
Assuming that certainPath folder end with \ ( es. "C:\" ), this should work:
Dim PL
PL = Shell(chr(34) & "c:\Program Files\VideoLAN\VLC\vlc.exe " & chr(34) & chr(34) & certainPath & "Movie 6.flv" & chr(34) & " " & chr(34) & certainPath & "Movie 7.flv" & chr(34))
CHR is a function to returns the character from the ASCII table (the quotes in this case).
I have an issue, have an AutoCAD file with a ton of data links and would like to update only the data links related to a speciffic table.
Simmilar to the functionality of selecting a table with data links, right clicking and selecting Update Table Data Links.
i have the following code:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "K" & vbCr
End Sub
It works but updates all the data links in the drawing (which is a problem) so a perfect solution would either let me get what links are associated to tblRef
and change the line to:
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "D" & vbCr & "datalink_name_from_tblRef" & vbCr
or directly send the command to update the links to tblRef
After much digging around and a lot of help, here is the answer:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE " & vbCr & "U" & vbCr & Ent2lspEnt(tblRef) & vbCr & vbCr
End Sub
Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function
note that "Update_table_data_link" has a table as input
I'm working with legacy code here and I'm not sure how much I could or should change, but I have code that looks for something like "SIC CODE 4000"
However the data html database I pull it from (we use a copy and paste) has updated their code to have:
"SiC CODE
4000"
Currently the code is:
Const strSic = "SIC Code "
However I now need it to add line breaks.
I tried modifying the code to say:
Const strSic = "SIC Code" & Chr(10) & Chr(10) & Chr(10)
But I get a compile error saying "Constant expression required"
I tried using "SIC Code \n\n\n" but maybe I'm not thinking the right character for line break.
Any suggestions?
The code for a new line is vbNewLine:
Const strSic = "SIC Code" & vbNewLine & vbNewLine & vbNewLine
Update:
To be a bit more detailed see the VBA constants:
vbNewLine = Chr(13)+Chr(10) on Windows and Chr(13) on Mac
vbCr = Chr(13)
vbLf = Chr(10)
So if you only need Chr(10) you should use vbLf (like Excel Hero's answer).
Try this:
Const strSic = "SIC Code" & vbLf & vbLf & vbLf
Yes vbNewLine is the correct code : )