I want to load one with data from a worksheet query table that will vary in size each time it's executed. The length will vary, but the range is continuous, and five columns wide. I'd prefer a do while loop, looping until a blank cell is encountered. Can someone get me started with general syntax and setup of the array?
I am try to Set a range to a variable. The problem is the range differs in size. The good thing is there is a blank cell before each group that I am attempting to set the range to. I know it should be possible to set the range to stop at the blank row. I am locating the correct row by the date and want to set the range to include the next three cells to the right and all the cells below them up to the blank row.
code to take jobs that are done on one spreadsheet and send them to the next available row of a specified range on another worksheet. I am also looking to incorporate a way to delete the empty rows that are left behind.
I have already made code to select the completed jobs, but am still unsure how to approach the next part. I can't even paste the selected range to another sheet without errors from range sizes.
The following code is done up to the point where I cut my selection.
Sub Update() Worksheets("OpenGen").Activate Dim c As Object Dim rngA As Range
name data1 data2 total chris a b 100 a a 100 a a 100 steve b b 90 b a 90 b a 91 jane b a 89 a a 90 a a 92
its hard to line things up in here..... anyway... each name has two more lines of data associated with it. i want to take the 4th column last line for each and sort from greatest to smallest and rearrange all the data but keeping all three lines associated with each person together. one added complication. the number of ppl in this will vary although i can do a count of every three lines and tell exactly how many there will be. so for this purpose we can just keep it at three.
in this case, all three lines associated with jane should be moved up above the three lines of steve but stay below the three lines of chris. and the three lines for each person stay in the same order they are now
I was looking for a worksheet with vba to do FFT beyond the Excel internal 4096 limit. I wanted to try my hand at writing code to do it faster. The attached does just that.
Everything worked fine until I went beyond 32k samples. The next higher 2^n value for data size to feed the FFT is 65556. When I tried this quantity of samples I got Runtime Error (13) type mismatch when attempting to write the array back to the worksheet using the "transpose" method.If I remember correctly, 32k worked.
Is there some limit to the size of the array that can be transposed and placed into a range? If so, is there another way to do this?
I do not need to re-write the data, but I use this same method elsewhere to write the FFT output. It it fails writing the input data back, it will probably fail when writing the FFT results.
I currently have a problem with suming the costs from tables across multiple sheets where the tables are of varying size.
Each sheet, 'sheet1' to 'sheet10' for simplicity sake, has a simple table consisting of two columns, 'Item' and 'Cost'. Each row contains a certain item and it's respective cost. The bottom of each table then has 'Total' in the item column and the sum of the total costs in the 'Cost' column.
However, each table on each sheet has a varying number of rows. This means on 'sheet1' the total may be in B5 and on 'sheet2' it might be in B7.
I need to sum all the total costs from 'sheet1' to 'sheet10' in a single cell.
I tried using the =SUMIFS formula with a 3D Range but I discovered that you can't use this formula with a 3D Range.
The only solution I could think of is to use a loop that goes through each sheet in turn, searches Column A for 'Total' and then adds the cell next to it to a running total.
I'm trying to load an array with numbers from 3 to SheetCount. If someone wouldn't mind giving me a nudge in the right dirrection, it'd be appreciated.
I have ten customers who have multiple locations where we do work. On ourinvoice I want to use Data Validation (list option) to read the input "CustomerName", and then change the validation list in the "Job Reference" cell accordingly. For example if A1 is the customer name and A2is the "Reference" where the data validation list will be. Customer ABC has 3 locations, XYZ has 5, CompanyD has 4, and so on. The range for thevalidation array is C1:C5. ABC's list oflocations is located at A10:A15, that of XYZ at A16:A20, and Company D atA21:A25 (and so on, for the others). Howcan I load the data validation range (C1:C5) with the correct list from, forexample A16:20 based on A1 being customer XYZ?
I have an array and I need to be able to detect when a varying number of consecutive array elements are equal. I want to be able to call the code and give the number of elements I need to find.
The following does not work but illustrate what I am looking for.
[Code] .....
I have been looking at ways of recording the number of equalities in the p loop, but I am sure there is a more elegant way.
I am attempting to have cells in Column 'U' deliver different drop-down menus based on the corresponding value in column 'D'. I have created 7 named lists:
Those lists will be called up based on 7 values in column “D”: “G” “152” “J” “X” “D/E” “V” “R”
So far I have only been able to get this to work for the first category “G”. When I change the value of column “D” from “G” to “152” I no longer get a drop-down. Here is the formula I am using in the List function of validation.
There are 11,000 rows and 4,000 are unique. The goal is to merge the data down to the 4,000 records. Each of the unique entries shows up 1 to 15 times.
In trying to solve this, I wonder if I should break this down into the different # of occurances and implement specific solutions. e.g., There are
5700 entries that show up 2x 504 that show up 3x 24 that show up 12x
I have created the attached spread sheet to work out and calculate gp on products. Sheets and userform1 are working perfectly how ever userform2 wont load and I believe its something to do with the named range? The idea for this userform was to select a product from combobox1 and then change the price on sheet1 and clear the price on sheet 2 in the different sizes.
Also userform2 i would like to create it so that if any of the fields are left blank it wont change price of selected field in sheet 1 and wont clear selected area in sheet 2.
Finally is there a way on userform1 to shrink the userform size depending on how many sizes are needed?
I want to call a macro with a varying name that is within a module with the same name.
I have a module called Test1 and within this, a macro name called test1 I have a module called Test2 and within this, a macro name called test2 etc
On another module called Test8 (with the macro called Test8), this Test8 macro will call either Test1 or Test2 or Test3 etc depending on what I choose in an excel spreadsheet. So on sheet1, cell A1, there is a drop down with the options Test1 or Test2 or Test3 etc.
The following works to run the macro test1 from module test1 (when it does not vary i.e. i physically put in the name of the macro myself):
Sub Test3() Test1.Test1 End Sub
The following works to run the macro test2 from module test2 (when it does not vary i.e. i physically put in the name of the macro myself):
Sub Test3() Test2.Test2 End Sub etc
However, if I try it so that the calling of the macro varies as below , it does not work:
Sub Test3() MacroToCall = Sheets("Sheet1").Range("A1").Value MacroToCall.MacroToCall End Sub
I have a named range that is 993 cells in length (columns). I verified this in the name manager. In my VBA code I am getting a range error when I try to access element number 903. 903 should be the last one with any data in it. I can't see a reason why this would generate an error since i have not exceeded my size of 993.
Is there a VBA function or property that I can use to determine the size of an array?
How to calculate the size of an input variant using UBound? Sometimes I need to do the transpose but sometimes I don't. I tried ON ERROR GOTO but it doesn't work in this case. Can you tell me how I could do that?
Public Function Shock(A_E As Variant, Year As Variant) As Double
I'm trying to set a range variable ('IngFore') as equal to a number of rows long and a number of columns wide via 'Cells'. The range needs to be dynamic in that the total number of rows and columns will vary over time. Hence, I've defined 'lastdate' to determine the last row in the array, and 'lastcol' to determine the last column in the array. The starting point for the array is I12.
It would appear that I can't quite get the syntax right.
Code: Set IngFore = (Cells(12,9 to lastdate,9)),(Cells(12, 9 to 12, lastcol))
I've tinkered with it here and there, removing and adding brackets but I can't get it to work.
I want to sum a range of cell in a macro. The range can change depending on what is imported. For instance, my range is from (Ax:Ay) and sums this amount on the cell below Ay.
I am trying to develop some code to serve as an 'undo' for several macros that I have. They each take a selected range and perform some changes to that range. I have managed to make some code that will undo the last macro run but would like to make something that can go back several steps. To that end, I have started with the following code but am running into an issue when I need to use a variant array to hold multiple arrays of a custom defined data type:
VB: Type SaveRange Val As Variant Addr As String
[Code] .....
This declares some public variables I'll need, each as an array so that I can iterate through several steps of do/undo using the undoIndex. I then use them to save each range I am about to change by calling the following macro within my actual data-manipulating macros:
VB: Sub Save_RangeForUndo(rng As Range) Dim i As Integer Dim cell As Range
undoIndex = undoIndex + 1
[Code] .....
If you look at the last line here, this is my problem; I can't figure out how to properly use an array to hold each instance of OldSelection() for later referral. Just for completeness, here is my actual undo macro:
VB: Sub Undo_Operation() Dim i As Integer OldWorkbooks(undoIndex).Activate OldWorksheets(undoIndex).Activate
[Code] .....
I need to get this OldSlctVariant()() array to hold each instance of OldSelection() so that I can restore them for each consecutive undo. I'm not very familiar with the variant type and anything more than the basic use of arrays.
I am trying to figure out how to make a userform to display the contents of a 2-D array which has a variable number of rows. I want the userform to height of the userform to correspond with the number of rows of data to display.
I don't have much experience with userforms, but here's what I was thinking: VBA code which would find the # of rows of data and then adjust the height of the userform and the length of the lable (which the data would go in).
I am working on an excelsheet containing a data dump from a manufacturing database. Inside this sheet i want to make subtotals of different production runs. The data that needs to be added up is in one big list between every production run there is an empty cel. So I want to make a formula that does: =SUM(one-cel-above-current:next-empty-cell-above)
I'm trying to sum a varying range of cells based on conditions in another column. right now im trying =SUMIF(B:B, "Active", C4:C10)
The number it is returning is not correct and I'm not sure whats wrong. Also, is there a way to allow the range of cells to vary? Like if I wanted to insert a row and have it included in the sum.
I have created a button to print an inventory list daily. The size of the list changes each day. The code I'm using works except I only want the Current Region to be defined as only the first 4 columns.
Private Sub CommandButton5_Click()
Sheets("Inventory").Select Selection.AutoFilter Field:=4, Criteria1:="Inventory" Set rng = Selection.CurrentRegion ActiveSheet.PageSetup.PrintArea = rng.Address ActiveSheet.PrintOut End Sub
I have the following code that let's the user choose and " import" data to an existing sheet. It works well up until now. The problem is that the three ranges that I am trying to copy the data from on workbook to another has changed size. In previous version of my workbooks the range was two columns by 10 rows. Now, it is 1 column by 10 rows. So, when I run this macro it doesn't work because the two ranges are different. Is there any way to: 1) Only copy over one of the rows of a range thus making the macro run?
2) Do not run that part of the macro if there is an error?
Thanks so much for reading this long-winded description but the error is a big problem