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
Related
I am trying to deal with some closed workbooks and tried to use ExecuteExcel4Macro approach and here's some hints
This is the normal formula
=SUMIF('[Example.xlsx]Sheet1'!$B:$B,C3,'[Example.xlsx]Sheet1'!$C:$C)
I used s string to store the address of column B and t to store the address of column t of the closed workbook
s = "'" & myDir & "[" & fn & "]" & "Sheet1" & "'!" & Columns(2).Address(True, True, -4150)
the same with the variable t but to change Columns(2) to Columns(3)
And in the immediate window I got something like that
'C:\Users\Any\Desktop\[Example.xlsx]Sheet1'!C2
Then I tried to use
Debug.Print ExecuteExcel4Macro("SUMIF(" & s & "," & Range("C3").Address(True, True, -4150) & "," & t & ")")
But I encountered an error Method ExecuteExcel4Macro of object _Global failed
Any ideas?
Another point how to get the worksheet name without the need to know the name by referring for example: Worksheets(1).Name in the variable s?
I noticed that the formula is working when the workbook is open but it throws an error #VALUE when the workbook is closed.
So I will try and be as clear as possible.
I am trying to make a macro that will populate and email with the following things:
Values from Listboxes
Writing for the main message
and a Table of values (which I've currently got being populated as a HTML body.
For example, I would like the email body to look as follows:
"Dear" [Name from preselected listbox]
"In order that we compile the latest update for the NAV please can you arrange the following information to be provided for" [The date]
[LIST THROUGH HTML]
"Please can you provide this information by the folowinf date"/....
I've currently got the list being pulled through correctly, but that has then stopped the vba body being entered. Therefore, the following code only pulls through the list.
Dim Addressee As String, SenRan As Range ' Define the receipient as words
Addressee = Application.VLookup(SourceLiBo.Value, Sheet1.Range("A1:B1000"), 2, False) 'finds the email address for chosen name
Set SenRan = ThisWorkbook.Sheets("Assets").Range("A1").CurrentRegion 'Selects the range of assets to be emailed.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.Body = "Dear " & Me.SourceLiBo & "," & Chr(10) & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & Chr(10) & _
""
.HTMLBody = rangetoHTML(SenRan)
End With
How is the best way to go about this in order to have all the data pull through. I would set variables with the strings wanted for the body and input it through .HMTLBody, but would that also allow me to pull through th listbox values in HMTLBody
I have now reworded it, thanks to braX explaining my errors. The code below (with the Ron Bruin Function) provides the correct answer.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.HTMLBody = "Dear " & Me.SourceLiBo & "," & _
"<br><br>" & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & _
"<br><br>" & _
rangetoHTML(SenRan) & _
"<br><br>" & _
"Please let us know if there are any additional purchases not reflected in the list above." & _
"<br><br>" & _
"Please can you provide this information no later than 10 working days from the date of this email to allow us to process all updates for delivery." & _
"<br><br>" & _
"Many Thanks"
End With
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"
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)
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