I need to calculate a formula in a constantly changing range. In the example below, the formula in column C would yield the % change in column A between the first "P" value in column B and the minimum value prior to the next "P" value.
So, the first result would be =(A2-A1)/A1, which is (1896.3274 - 1973.4764)/1973.4764. The cells in column C would be blank until the next formula, which is =(A8-A7)/A7, then it gets tricky. The next would be =(A14-A10)/A10.
A B C
1 1973.4764 P
I have a userForm (Form1) that contains a persons name that I would like to reference in a separate UserForm (Form2). In the separate UserForm (Form2) I need to reference this persons name many times, so I was wondering if there was a was to declare this name in the separate UserForm (Form2) as a constant. Only thing is that a constant, to the best of my knowledge, must be an expression and not a variable. Mainly, I'm trying to avoid declaring the myName variable in each Sub within Form2, which it will be needed for a ton of Sub's.
Code for Form2: Const myName As String = Form1.txtName.Value
I am trying to write a macro which will autofill specific columns. The macro will set the range from the start of my autofill to the end of my autofill as a constant range.
The problem I need to get around is the end of my range can always change each time I run the macro. For instance, the first time I run the macro I may only need to autofill from row 4 to row 15. The next time, I may only need to autofill from row 4 to 23 (because of user updates). How can I make the end of my range not be a constant address but variable?
is there a way to do this in VBA? I've also read: - Dave Hawley's recommendation of using: Sheet1.UsedRange.SpecialCells(xlCellTypeConstants).ClearContents
from another thread (which is excellent!)
- SHG's recommendation of using a named range, for example:
Given my limited knowledge of VBA, how would I now combine the two to write a VBA sub-routine that clears a named range entitled "Entry" on a sheet entitled "Data"? Would the following be the correct syntax: Worksheets("Data").Range("Entry").SpecialCells(xlCellTypeConstants).ClearContents
I have a list of filenames in Sheet1, range A1:A20. These files can be found in URL http://mysite/x/y. Where y is the filename (including the extension) and x is the 1st 4 characters of the filename. So if in A1 I have the filename AB1234.pdf, this can be found in the link: http://mysite/AB12/AB1234.pdf. Is there a was in VBA where I can loop thru the list in A1:A20, and copy each from their respective URLs and save into C:Documents and Settings ?
I paste new data into a sheet of a monthly report I prepare. For this sheet, the # of data rows change (and is unpredictable) every month. I need the value inside a specific cell that dynamcially moves up and down based on the # of rows for that month (because it's below the rows of data).
So I made a formula to identify the exact cell # every month.
This month the exact cell is F255 in the "Refi" sheet.
So my formula in the "Summary" sheet cell A1 first finds the cell row # only (255) and since it's always column F, in B1 I have
VB: ="F" & (A1)
This outputs "F255" in B1, successfully identifying the target cell.
Now how do I write a formula in C1 to grab the value from whatever cell is named in B1. (For this month, the value in cell F255 from the "Refi" sheet)
I have a range which will change in size & in content, & I want this to be a Named Range at whatever size it is.
Reason I want to is because I want to make a Validation List with this dynamic range. I also want a Validation list which lists the content of 2 or more dynamic ranges which may or may not be on the same worksheet - is this possible?
i.e. First dynamic range: called "Milestones" at A11 Second dynamic range: called "Activities" at A25 & make a Validation list that will list content of both
I am developing a macro to select cells within a worksheet based on certain criteria and to make a list of their range names. My approach is to copy the range names to a column of cells using something like the following text:
but I get an error message saying "Object doesn't support this property or method". Why can't I copy a range name, and is there a way to work around this?
I'm trying to create a list of missing numbers in a range, but I can't fiure out how to do it. The problem lies in that the range of numbers is in the middle of a larger number. ie. xxx-xx-0001-xx would be number 1, and xxx-xx-0500-xx would be number 500.
I need to scan multiple sheets containing these numbers, and produce a list of the numbers missing from that range.
Sheet1 has xxx-xx-0001-xx through xxx-xx-0009-xx, and xxx-xx-0018-xx through xxx-xx-0042-xx.
Sheet2 has xxx-xx-0053-xx through xxx-xx-0062-xx, and xxx-xx-0067-xx through xxx-xx-0072-xx.
Sheet3 needs to have a function that produces a list showing xxx-xx-0010-xx through xxx-xx-0017-xx, xxx-xx-0043-xx through xxx-xx-0052-xx, and xxx-xx-0063-xx through xxx-xx-0066-xx.
I need to be able to do this without VBA. The list doesn't necessarily have to have a different number per cell, it could even show them all on 1 cell if it's easier, but it would be more presentable if it was 1 number per cell in a row or column.
I want to select the cost for fuel based on the date using the select case method.
Sub FuelCostApplication() Dim Check As Integer Do While Check < 10 Select Case Range("B4").Value Case 8 / 30 / 2007 To 9 / 5 / 2007: Range("C10").Value = Range("B4").Value ActiveCell.Offset(1, 0).Select Case Else Range("C10").Value = 0 End Select Check = Check + 1 Loop End Sub
CREATE TABLES LIKE BELOW? -----------A----------- ---B---- --C-- --D-- --E-- F 1 US Air - Ground Expense 2 Fuel 3 Week1 Week2 Week3 Week4........................
I am having no success using either: 1) COUNTIF with wildcard (*) or 2) Case Statements to find text strings in a cell. I've even tried using Copy/Paste Special values to change the way Excel 2007 interprets the field.
The Do While loop looks at target cells in Col. 18 which contains one or more specific last names. I want to put a text string (also a name) in Col. 19 IF the target cell contains the last name in the COUNTIF or Case Statements. The COUNTIF normally puts a TRUE or FALSE based on the condition, but I'd like to put the the last name based on which condition is met and then continue looping to Row 3. It's a small number of rows, less than 100.
I'm looking for a way to identify the first cell of a page without using the pagebreak function: Sheet6.Range("B" & Sheet6.HPageBreaks(i).Location.Row). The reason being is for overall speed and performance as well as avoiding <out of range> errors on the last break. If I use totalPages = Sheet6.HPageBreaks.Count + 1 to determine the number of page breaks, is there a way to identify the first cell of page i in this way?
I need a macro to identify when cells are >= 90% in a range, and count them. Then put the result in cell Z58. Range is I51,L51,O51,W51,Z51. i.e if all cells are 90% then put value of 5 in cell Z58. Here is code i have that isnt working:
I have a column of data that keeps getting new information in it. what i need is a named range that i can use for a chart, first point in the named range will be the first value in the column, second point will be avg. of point 1 and 2, then 3rd point will be avg. of 1,2,3 etc.
I have a range of data that will grow as the days of the month pass but I need to run calculations on this range. The data is 13 columns wide but the number of rows will increase daily. I remember using a formula in the Define Range that would automatically take into account new additions using the OFFSET function but cannot for the life of me think how exactly to do it.
I have been working on part of the code for my spreadsheet and it works fine in the spreadsheet “Databaseform” however when I copied the code to my master spreadsheet “Paul_PartLocDBCombo” it does not work, I get the error:
Method ‘ range’ of object ‘_worksheet’ failed The code is then highlighted in yellow, the code is: Set rng = wksPartsData.Range("a1", Range("a65536").End(xlUp))
Meaning this part is incorrect but I don’t know why? To work it: go to Databaseform and press start. Enter 7mm in the product field and press find all. It will then return all the matching results in the userform. Its this I want to try and achieve on the other spreadsheet when the button find label is pressed.
I have this macro named ABC to bring the name ranges to another worksheet. The name ranges are already saved in the workbook with the below name range. I used "***" so that this formular can go to the last cell that has "***" on A column and it worked untill someone typed "(xxx)" and the range now stops right before the "(xxx)"
I am looking to sum a dynamic range and can't quite figure it out. The data expands down rows every week, and I want the sum formula (the final row) at the bottom to include the newly updated rows. I can't dynamically name the numbers to be summed because the dynamic named range will include the sum number and create a circular reference. For example:
5 4 3 2 14
the bottom row (14) is the sum. Next week, my numbers are
5 4 3 2 5 19
I have a macro that will automatically put the sum formula in the correct row and column, but can't quite figure out the formula.