I want to create a function in a module that will read an array from sheet1 preform an operation on it then return the result to the spreadsheet in a defined amount of cells in this example 8.
In Module1:
VB:
Function func1(ByRef arrayA())
Dim arrayB(8)
For k = 0 To 7
[Code].....
How does the resultant arrayB get populated onto the spreadsheet?
I have a seemingly simple dilemna and wonder if there is a solution... I am not a PRO user, but can get by with my limited knowledge of excel.
My issue:
I create invoices for my business and in the invoice I use the "TODAY()" function to automatically insert the current day when I created the invoice.
Now when I need to go back and look at the old invoice or print it again it shows the CURRENT date, not the original date when it was saved. Is there a way to view and/or print out a file while keeping the original date intact or is there a better way to format a date to avoid this happening in the future.
I have since eliminated the function and just type in the date to avoid this but I have about 100 invoices that are saved that I may need to view their "original" dates on.
I would like to know if there is a way to print several different workbooks at once but keeping my printing format which I would like to be Landscape and Fit to one page. Reason is simple as I work in a office where staff is handed in several jobs to do everyday. They finish the jobs and log all the info on the database. I log on to database and put all their daily diaries and because it is all over the place I have to go in each file and set printing preferences which takes an hour in the morning and hour in the evening. I could do with some sort of automation where all diaries are automatically printed in Landscape and Fit on one page.
I have a report that is generated from a manufacturing process that looks like the example below. the report is 40 pages long when all the data is printed. i am looking for a way to only print this range if a dimension is "out of tolerance". if the dimension is within tolerance, there is always the "garbage" text of plus and minus. if every row is "within tolerance" in the range the cells in the OutTol column would all contain the "garbage" text but it will not always be identical. so, in summary, actual OutTol values = print and all "garbage" = not printed.
The array sum function works but Concatenate not. In Excel I get the formula Concatenate(H2:H3) in stead of Concatenate(H2,H3). What should I change to get the code working?
I want to use the countif function for a certain array. The range is set by another cell which is made up out of a percentile of an entire row.
The problem is is that excel doesn't see the value it displays so i continuously get a value of 0 in the countif cell. If i fill in the range by hand, which is exactly the same range as the outcome of the percentile the countif cell does give the correct value.
So in short the problem is i guess that the countif cell does not recognize the value because this value is made up by a formula.
I am working on a Monthly Vehicle Spread Sheet. One of the outputs I am trying to achieve is an automatic calculation of Mile Per Gallon. To do this, I need to know if there is a function that will return the value of the first entry of a group of cells.
In calculating the miles per gallon, I need to subtract the first gallon amount entry of the total gallons in the month, then divide that number into the difference of the mileage in the month recorded when the vehicles fueled up.
I am trying to write a code for simulating a stock price using geometric brownian motion. I have the function part down as follows:
Public Function SimStock(Initial_Stock_Price As Double, _ Expected_Return As Double, _ Volitility As Double, _ End_Time_Days As Double, _ Number_of_Steps) As Double SimStock = Initial_Stock_Price * Exp((Expected_Return - Volitility ^ 2 / 2) * (Number_of_Steps / End_Time_Days) * NRnd2() * Sqr((Number_of_Steps / End_Time_Days))) End Function
Now what i need to do is to apply this to an array. so that when i run the sub it will simulate prices from today up to some number of days that i specify. This number of days will be equal to "End_Time_Days" which is part of my function. Furthermore the simulation has to be such that it uses the above formula for the first entry but then replaces "Initial_Stock_Price" with the result of the preceding entry in each subsequent entry.
For some reason my array called "PriceSum" is not getting load with values or not being summed. I am not sure if it is because I am trying to load a value with a decimal in it or not.
Code: Private Sub Purchase_Click()Dim MyArray As Variant Dim x As Integer Dim t As Integer Dim lastrow As Integer Dim QuantityArray(0 To 1000) As Variant,
I have a big macro that runs whenever there is a change made. I'm not gonna link it all because I don't think that would be useful... This macro does:
1. Disables Events. 2. Removes Protection 3.Calls some macros that check a few values and change a few cells. 4. Activates events. 5. Hides or shows ranges of cells depending on the results of the called macros. 6. Reactivates protection.
As well as the cells the called macro changes, there is a column of True/False results stretching from AE16 to AE491 with several blanks in the list as well. (All of this is decided upon a different macro that isn't linked with the change.) I want a loop that will read the True/False column and if it finds a false, make 8 buttons invisible.
I tried putting this code between Step 5 and 6 of the macro.
Code: Dim J As Integer J = 16 Do
[Code].....
This isn't working at all... I was thinking if there was gonna be an issue then it would be the opposite where it stops the buttons appearing all together but even when there are falses and I am changing things it doesn't seem to make a difference.
I'm just getting into functions, so please bear with me on this as I start to understand how they really work. I do have the VBA and Macros for MS Excel book which has been a great help!
Normally on this I would use a simple array formula to gather a total calculation from a timesheet, but in this case there can be numerous timesheets to add this up.
Hours would be recorded on a sheet with both a client and a task selected. I also have a summary sheet to show clients against tasks... adding all the hours from each timesheet.
If it were from a single Timesheet (possibly creating a single one of these for all sheets is an option?) I would be able to use the following array formula:
=SUM(IF((Timesheet1!$F$8:$F$22=C$5)*(Timesheet1!$G$8:$G$22=$A9),Timesheet1!$D$8:$D$22)) Timesheet1 Column D = hours Timesheet1 Column F = clients Timesheet1 Column G = tasks Row 5 (starting Column C) = clients in summary sheet (across top) Column A (starting Row 9) = tasks in summary sheet (down side)...........
I am trying to write a public function that fills a table for a 2-dimensional array and am having trouble with my named ranges. The x-axis is based on years (range F2:O2) and the y-axis is a q_factor (range E3:E23) so the data range would be (F3:O23. The following outlines my logic:
Public Function bondValue(years As Range, q_factor As Range, z As Double)
Dim nRow As Long, nCol As Long Dim bondPort As Range
I have written the code below. But it didn't work. In my opinion the error is most probably caused by irr worksheet function. Because the code is actually bigger and I tried it all part by part.
Option Base 1 Dim i As Integer Dim j As Integer Dim counter As Integer Sub General() 'Makes general calculations Dim Cash_Flow_Project_Entity(49) As Variant 'Toplam Yatırım Nakit Akımı Dim FIRR(49) As Variant 'Yearly FIRR Analysis_Period = Worksheets("Veri"). Cells(15, 5) 'Takes " analysis period" from "Veri" Worksheet End Sub
I have the following assignment to do, problem is I'm new to arrays and functions in VBA and nothing is working for me, i get errors no matter what i try, (for example i don't know how to feed the array to the function, and it won't let me write a range to an array)
5.A) Write a function that takes a 2D array of doubles, a single cell range, an optional cap and an optional floor. B)Write the array on to the sheet with the single cell range parameter being the location of the top left of the array on the sheet. When writing the array to the sheet, for each value in the array where it is below the floor put the floor on the sheet, where the value is above the cap put the cap value on the sheet, otherwise display the original value. The input array should not be modified. All code should be what you consider production quality.
How can I obtain the array values from a function?
For example: Those steps were made by cytop to split a text (btw it works perfecet!!), I just added Function splitText(strSplit As Variant) As Variant ... End Function
VB: Function splitText(strSplit As Variant) As Variant Dim datosColumnaIncio() As Variant Dim iTemp As Integer Redim datosColumnaIncio(Len(strSplit) - 1) For iTemp = 1 To Len(strSplit) datosColumnaIncio(iTemp - 1) = Mid$(strSplit, iTemp, 1) Next End Function
So I want to know if its correct like that:
VB: Function splitText(strSplit As Variant) As Variant Dim datosColumnaIncio() As Variant Dim iTemp As Integer
[Code] .....
So when I call the function:
VB : MsgBox splitText("F4")
It throws an error message :s what is wrong or how can I get the array values of a function ???
Please see the attached worksheet for details. I would like the array function to search for instances of the word "FALSE" in column E and return the values of columns A:D when a match is found. I have done this successfully when the lookup value is a value in the first column of the range, but cannot seem to do so when the lookup value is in the last column of the range. I have received a #NUM! error each time.
I have 15 toggle buttons that are each tied to a unique value. A toggle button identifies the value as either Active or Inactive. I then want to add a command button that will produce the product of all the Active toggle button values.
For very few togglebuttons I can use a code similar to the following (adjusting for the number of buttons)
Code: Private Sub CommandButton1_Click() If ToggleButton1.Value = False Then Sheets ("CTG Calc").Range("e50 = Sheets("CTG Calc").Range("E47") * Sheets("CTG Calc").Range("E48) Else Sheets("CTG Calc").Range("E50) = Sheets("CTG Calc").Range("E47") End If End Sub
However, when I get more than just a couple togglebuttons it becomes very unwieldy to have multple If then statments for a True/False option for all 15 buttons. I know there is an easier way to do this with some kind of array function that will look at each toggle button separately anf if the togglebutton value is false will generate the product of all false togglebuttons and ignore the value of all true toggle buttons.
Any way with standard excel array functions to achieve a mirroring of a vector? I would like to use it in further calculations, thus a cell-by-cell OFFSET(.) solution unfortunately does not work for me.
Basically I want to return an array (to pass to another function) containing all data that matches my search. E.g. I want to retrieve an array of the data that matches 2013-09-20. Is the only way to do this a VBA func?
I have this MAXIF array function that I am trying to use but I need it to reference the Last Row and not the absolute refererence. I am a novice at VBA. The first max if array is the one with my effort to try and get the last row. It doesnt work. The second one works but references the cell.
I need a look-up function that can return a value from an array that can be 3 to 7 rows in height. I want the function to always look at the last row in the array.
This is how it looks:
Column A Column B blank row 1000 A B C SUM 15 blank row
In this case I want the function to return 15 if I search for 1000. The problem is that there are not always a fixed number of rows beneath the searched value.
I'm trying to pass a multidimensional array to a function that I have defined, but I receive an error about an object mismatch. Here is what I have in regards to the array and function. What should I change?
Code: Dim diffArray() As Integer Dim countArray() As Integer Redim countArray(count,2)
diffArray = getRunningSum(countArray) End Sub
Public Function getRunningSum(ByRef countArray() As Integer) As Integer() 'Code here...... End Function