Range Object/property: Calculates 2nd Column Based On 3rd Column's Number
Jun 1, 2009
I'm trying to write a code that calculates 2nd column based on 3rd column's number or vice versa based on the condition set on the 1st column. Below, there are two procedures. "SimpleCalc" and "SimpleCalc2". I first wrote SimpleCalc2, but it isn't working, so I worked around the error by writing SimpleCalc, which selects a cell and moves around by offset. I personally find it hard to read and error prone as I develop more logic around it.
I'm trying to develop more function based on this code, so I need to make it neat and flexible. what I'm doing wrong in SimpleCalc2? Or do you have any suggestion to improve the code "SimpleCalc"? I'm using Excel 2003.
Sub SimpleCalc()
Dim SimpleMethodRng, SimpleMethod As String, i As Integer
Is there any formula that could calculate total average number of recruitment days (i'ts one number), but only for "Diana" and "Skipper" (excluding "Jennifer")?
Please see attached sample worksheet. Column A will be generated by the user manually.
I'm looking for a way in VBA to have A1:D20 in Sheet2 copied and pasted in the "Bank Reconciliation" Sheet based on how many "Markets" there are in Column A. Then, once that's complete to have A22:D30 (the smaller box in Sheet2) copied and pasted directly below those results.
I have what the macro would hopefully generate to the right in "Bank Reconciliation" (B6:E54) as an example. So if there's a market in A1, copy and paste the box to B6. If there's a market in A2, copy and paste the box directly below the first (B26) etc. etc. until it's done, then paste the smaller box directly below whatever the macro generates.
I have the following sample data set and I'm trying to return the appropriate column header based on criteria (i.e. DDD) and a number value which will be somewhere within the range of the table. In example below, the value returned should be Header 2 because the value is greater than those in Header 1 column (range H9 to L26).
But the number of columns is dynamic, so I don't know which one is the end. So I have the column number but cannot figure out how to reference the column range by number. I have tried versions of the code below but they all give different errors. This one is Run-time error 1004 Application-defined or object-defined error.
I'm still confused regarding a complex formula - rather n00b. Using Office 2007 with XP. Can't figure out with help or previous questions.
The following is what I would like this formula to accomplish. Picture included below.
Take all the values of column of C and add them together if and only if the corresponding date value in column A is during the month of January (and February, March, and so forth).
in column B of sheet1 i have every 3rd-4th row a name. i need to copy the name and the the data on the row below the name to sheet2, the list of names can be min 2 max 30.
so sheet 1 has row 14- name in column B and C. in row 15 in columns d:z data for the name.
i need to copy this to one row in sheet 2 copied for each name up to 30.
I'm trying to write some code to make an existing chart display the correct series of data. However, on the ".SeriesCollection..." lines, it gives me the error "Object does not support this property or method." I'm using a Bar-Line graph, if it makes any difference.
I have got a UserForm which pulls data from Excel sheet and show it on UserForm.
UserForm1 has One ListBox name "ListBox1" and Thirteen TextBox's.
TextBoxBatch...... Showing Batch number TextBox1 ........... Showing Year 1 data TextBox2.............Showing Year 2 data TextBox3...............Showing Year 3 data . . . . TextBox12...........Showing Year 12 data
It shows data correctly in UserForm1 for TextBoxBatch and TextBox1 to TextBox9 but when it reaches TextBox10 it give error "Could not get Column property, Invalid argument"
And it does not show data in TextBox10 (Year 10), TextBox11 (Year 11), and TextBox12 (Year 12).
I have named ranges in my excel sheet.I wish to however find out the column number from each of the names and use it as a variable for later calculations.How do I do this?
I need to build a formular in a cell that uses various columns in it's row such as: =A2+A4+A17+A24. In the past I've used simple number references to the columns (a is 1, b is 2,.....) I can't do tht though if I'm using a macro to automate the creation of a formula, right?
Is there a property I'm missing that will return the letter reference to the column instead of just the number as Activecell.column does?
My alternative is to write my own code to do this, but you know the bit about not reinventing the wheel....
I have a list in Excel with several hundred 8 digit ID numbers in column D. Column C contains the total number of hours the student employee worked. Column E needs to calculate using two different equations depending on if the ID number in column D is a manager's. If the ID number is an employee the total hours worked is divided by 8. IF the ID number represents a manager the total hours worked is divided by 4. I've attempted this by using an array for the manager ID list and also using VLookup without success.
In essence I need to loop through column D, check which type of ID number is present, and then enter the correct formula in column E.
When I run my code (which opens Excel from Access) it does everything it is supposed to but I then get the above error but I do not get the error if I open the VBA window and then run the code. (The code is password protected, not sure if this is relevenat though).
I'm getting a really weird error in that I can't reproduce it. It sometimes occurs when I open the document and sometimes not. HEre is the Private Sub Workbook_Open() Dim dic, Dn As Range, rng As Range
Set rng = Sheets("Moisture").Range("B2:B1000")
Set dic = CreateObject("Scripting.Dictionary") With dic For Each Dn In rng If Not .exists(Dn.Value) Then .Add Dn.Value, ""
End If Next Dn Set wksPayment = Sheet10 wksPayment.ListBox2.List = .keys End With End Sub
The line that hangs up is the wksPayment.Listbox2.List = .keys line. Any ideas or ways to test or further figure out what is causing the problem?
I am trying to calculate some averages. What I have is 3 columns of data in A, B, C, also the "tasks" in A are in named ranges ex: "Award Contract" is a named range - "Task_Award" and "Confirm Updates" is a named range - "Task_Updates". I've attached a sample excel sheet.
I'd like to be able to create a macro to evaluate column A, and for every row in range "Task_Award", give me the average of the corresponding cells in column C and put it in the same range of cells in column B , then, for every row in "Task_Confirm" then give me the average of the same range of cells in column C and place the result in the same range of cells in column B. This is my very first post so I hope I am doing this correctly. I have 77 of these task ranges to evaluate and it will take a long time to do it manually. I'm thinking of a loop function.
I have a name in cell A1 and a number of 20 in cell B1. Is there a function to copy the name in cell A1 the number in cell B1 (20 in this case) times into column C?
I have a column say column B for example that has a list of dates in the format dd/mm/yyyy. I would like a summary at the top of the columns to state how many dates there are for the current month. But I wondered if this was possible based on the TODAY() function or similar. Thus the user would not have to change anything.
So for example at the start of the month it may state 14. Half way through the month down to 6 and at the end of the month 0 for example.
I have formulas in cells B8:F8. I need to copy these formulas down based on the number of rows in column A that has data. The data in column A will vary based on user input.
I get this work a lot and am looking for a much more effective way of working the dataset,
I have numbers like 1.1, 1.2, 1.3 and so on....... These come under criteria like (1) = 1.1, 1.2, 1.3 and so on.....
I am look for an automated way of doing a count of any number that falls under this criteria, so I want to count based on criteria (1) it would count all 1.1,1.2,1.3 and so on as one count.
I am attaching a sample document to see how it is laid out. [URL] .....
I would like to highlight the cells in Column A the have numbers in them. Starting with that number shift down based on the number that many rows and highlight them.
I WANT it to search all of column A for the highest number in the range (which will change daily to a new high number above the highest currently), and return the value in column 4 (column D) that corresponds to that value from column A. This is what I have, but it is not working, it is giving me the number (1) in Cell A800 (which is the lowest valued number in my range. The numbers range in value from 1 to 762 with none repeating (they are sequential). The formula I have is : =+VLOOKUP(MAX(A76:A2000),A76:I2000,4)