how can I get the complete list of Analysis Tookpak -VBA functions so that they can be written in VBA codes when the addin is referenced directly in VBA? For example, "histogram" function is referenced like this:
'Vba Code
sub atpsub()
histogram Candle_data.Range("L:L"), Sheet1.Cells(1, 3), Sheet1.Range("a1:a12"), False, True, False, True
End Sub
Problem is I don't know the names of other ATP fucntions. Thanks in advance.
Related
I wrote a public function in VBA which make a HTTP-request to a Website and returns back a double value.
I use the function in 5 cells. When i open the Excel-File the cells don't update automatically.
How to setup Excel to execute the SelfMade public functions in some cells?
I have tested the following VBA statements but nothing works.
Private Sub Workbook_Open()
'Application.Calculation = xlCalculationAutomatic
'Application.CalculateFull
'Application.CalculateFullRebuild
'Worksheets("Aktie").Activate
'Range("J3:J6").Calculate
'ActiveWorkbook.RefreshAll
'Range("J3:J6").Select
'Worksheets("Aktie").Range("J3:J6").Calculate
End Sub
What i am doing wrong?
Which settings i have to make?
Where to put he VBA code to autoExecute it when open the XLS?
The solution for this problem is:
i have had the code in the wrong Object/module.
i putted it in Microsoft Excel Objects \ This Workbook
and Worksheet5 (Aktie).
Before i had it in Module \ modul 1 where i have the public functions too.
I'm recently learning VBA and making my own UDFs.
So I need some references and built-in functions (like vlookup) must be good examples.
Is there any code open?
Thank you
This should work for you.
Function MyLookupFunc(v As Variant)
MyLookupFunc = _
Application.WorksheetFunction.VLookup(v, ActiveSheet.Range("A1:B100"), 2, False)
End Function
Use in a cell formula like ...
=MyLookupFunc(A1)
I am having trouble concatenating two columns (variable range) to another column in the same document. Is there something really obvious I'm missing?
Function ConcCol(ConVal_1 As String, ConVal_2 As String)
Range("V30:V500").Select
Application.CutCopyMode = False
With ActiveCell
.FormulaR1C1 = "=CONCATENATE(RC[5],"" "",RC[6])"
End With
Selection.AutoFill Destination:=Range(Destination), Type:=xlFillDefault
End Function
When running the above function, I get the following error:
Error: Run-time error '1004': AutoFill method of Range class failed
I assume it's something to do with only one cell being activated perhaps? My VBA knowledge is limited
Sub ConcCol()
Range("V3:V500").Select
For Each Cell In Selection
Cell.Value = "=CONCATENATE(RC[5],"" "",RC[6])"
Next Cell
End Sub
I think it'd be easier (if you're going with the selection idea), to just use each cell. I think your with statement doesn't want to loop at all, hence error. This works, a simple solution.
I think this is what you're looking for:
Sub tgr()
With Intersect(ActiveSheet.UsedRange.EntireRow, Range("V30:V" & Rows.Count))
.Formula = "=AA" & .Row & "&"" ""&AB" & .Row
End With
End Sub
Hey I think you are a bit confused. How do you plan to run this code? You need to provide more details. Here are three ways of running a vba code:
User Interface as a User Defined Function (UDF)
As a Function that is called/used by another VBA code
AS a macro and user need to run it from the macro list
For your purpose, why doesn't the user use CONCATENANTE function in the sheet and fill down?
Maybe use the Excel array functions?
I cannot post images, need 10 reputations :s
I'm trying to use the error function and the complimentary error function in my program. Neither are working. I keep getting the error Compile Error: Sub or Function not defined. However, if I go into a cell and manually try to use the error function, it works.
Why is that? How can I use it in my actual code?
The error function is ERF(x) and the complimentary error function is ERFC(x).
Here's an example of things that don't work:
Sub SeriouslyWHYIsntThisWorking()
x = 3
Range("A1") = Erf(x)
End Sub
Even this doesn't work:
Sub PleaseWork()
Range("A1") = Erfc(1)
End Sub
But if I went into Excel and typed =ERF(3) or =ERFC(1) into a cell, it'll work.
I'm very new to this and probably missing something incredibly simple. Help would be greatly appreciated!
Do you have the Analysis Toolpak for VBA add-in installed/referenced? (Look for atpvbaen.xls)
The ERF function is part of that add-in, and there are two versions of it (one for use in Excel functions, and one for VBA), and you'll need the right one set up and referenced by your project to be usable.
The add-ins are standard from MSFT, but not always set up by default. If you can use it in Excel normally, then you've already set up at least the Excel version. So using it all like it looks like you want to do will require the add-in, regardless of how you implement/use that function. Meaning, if you want to share this with anyone else, they will need the add-in installed/activated.
To link together this answer with the others provided (which are equally accurate and correct), either setting a cell value with
Range("A1").value = Application.WorksheetFunction.ERF(x)
or setting a cell formula with
Range("A1").Formula = "=Erfc(" + x + ")"
will require the end-user using the add-in.
To use a worksheet formula in vba, you need to put Application.WorksheetFunction. in front of it.
Some functions do have vba equivalents, but (as far as I know) not in the case of erf and erfc
Try this:
Sub ThisShouldWorkNow()
x = 3
formula = "=Erfc(" + x + ")"
Range("A1").Formula = formula
End Sub
Totally untested, since I don't have Excel on my Linux machine... But I think I'm getting the point across -- you need to use the .Formula property of the Range object.
There's more information here:
http://msdn.microsoft.com/en-us/library/office/gg192736.aspx
I have a problem moving a Word template from Word 2003 to Word 2007
The code which I need to convert is
Sub Standardbrev()
Documents.Add Template:= _
"p:\setup\stdbrev.DOT", NewTemplate:= _
False
mask "<Navn>", False
mask "<Adresse>", False
mask "<Postby>", False
mask "<att>", True
mask "<Jura Nr>", False
mask "<Vedr>", False
mask "<Jurist>", False
End Sub
Edit, problems:
When I try to copy/paste the code to a dotx document I get a compile error saying:
Sub or Function not defined.
If I outcomment the maskpart I can run the macro and it opens the stdbrev.DOT file in a new window
Edit: What it do in 2003:
When you run the macro a 7 boxes (1 for each mask) pop up where you can fill info into them. The info the replaces the mask fields in the document
Hope this explains my problem
Edit: I found the solution, I misunderstood some of the code and did not know that mask was a function written by someone else a long time ago. Sorry for posting this noobish question
mask is not a built-in function. This function should be defined somewhere in a module and you also have to copy this function to the Word 2007 document (That is why you get the error "Sub or Function not defined."). You can see where this function is defined by right-clicking on mask and then selecting Definition.
However, the easiest way to "migrate" this would be to simply open your Word 2003 document in Office 2007 and then save it as either .dotm or .docm file (depending whether you want to create a template or a regular document).