I will preface with what I am trying to do. I want to populate a combo box with months. The list will be populated based on a the date range in a dataset, so all 12 months may not bee populated in the combo box. I want the months to be listed in the combo box with their text names displayed(Jan, Feb... Dec) but have their numerical values when selected (1,2... 12). I'm sure there is a way to do this, but for the life of me I can't find how. My initial thought was to assign a value to a specific list index, i.e. assign the value of listindex 6 as "Jun", but I can't figure out the syntax to do that.
This doesn't work, but might give some insight into what I am trying to do
I have a form created, were the user can select up to three pairs of open worksheets for sheet subtraction, to see where Im going with, aka the big idea see here: Column Subtraction With Criteria Via Box & Produce Results In New Workbook
What I dont know how to do, is get the form in the attached workbook to show all the available worksheets. Specifically, from the dropdown combo box, I would like it to list all open worksheet title in all open workbooks.
Is it possible to count the number of comboboxes on a userform? Or better yet can I fill an Array with all the combobox names on a userform? I can count the controls on a userform but I'm trying to count just the comboboxes? Instead of all the labels and textboxes and frames.
I would like to loop through them for validation instead of doing it by each one by itself!
in A1 there will be a box with LinkedCell set to A1 and ListFillRange set to B1:B5. I now want a similar box in A2, with A2 as LinkedCell. However, when I copy paste the box in A1, it still refers to A1 and B1:B5 (the last part is ok). I can easily change A1 to A2 by just changing it in the properties, but the thing is that I also need these boxes in A3:A100. Someone else helped me out by writing some code, but this is not working correctly yet, probably because I'm doing something wrong.
Also, the ListFillRange might expand in the future. Therefor I would like to know if its possible to select the boxes in A1:A100 and change the ListFillRange to B1:B6 for all at once, or even have a piece of code attached to a command button that recognizes the expanded range and updates it.
I couldn't attach the file because it was to big, therefor I uploaded it with yousendit: [url]
So in short: I would like all the comboboxes in column E to be linked to the cell underneath and have and option to adjust the listfillrange. The same for column F, but for this one the listfillrange needs to be O8:O11.
I am trying to enter only the named ranges in the active worksheet into an Array. The amount of named ranges can be from 4 to 7 per sheet.
I'm self taught at VB (This posts on this forum have taught me - thank you!) and have got the below code working on a Workbook - but not on a worksheet level. ActiveSheet.Names.Count returns nothing, changing to ThisWorkBook.Names.Count returns the sum of all .Names in the workbook.
Sub aTest() Dim sArray() As String Dim sJoin As String Dim y As Long
x = 1 y = ActiveSheet.Names.Count z = ActiveSheet.Name
I have written this macro to convert into a csv file to run for all defined named ranges in the activesheet. It run jst perfect when I hit SAVE button and it creates that many different CSV files for each named range.
However I am trying to use same macro in the another file and the problem I am facing is there a lot more named ranges and I want to run the macro for only selected NAMED RANGE. In this case 2 Named Range / 24 Named range.
What part of code do I need to change and to what to make it work for just 2 named ranges ?
I need to create a named range on multiple sheets with the same named range & i cant figure out how to do this. EG :- I want to create a named range called "_SubUnitRows" on sheet1 starting from "A1:A50" & other named range again called "_SubUnitRows" on Sheet2 starting from "A1:A25" ...
I would like to combine List1 and List2 into a 3rd named range called List3. I was wondering if this were possible without using any additional cells/columns (i.e. I don't want to use Column C like in the example shown in the link above).
'i use a combobox in a userform to show data from a hidden sheet its name is sheet5(sheet1). 'i defined the Range as ExpCat and put ==OFFSET(Sheet1!$M$3,0,0, COUNTA(Sheet1!$M3:$M9),1) 'and use this code to view the data, but the code shows the data of the activesheet.
Private Sub ComboBox1_Click() Me.ComboBox1 = ThisWorkbook.Worksheets(5).Range("ExpCat").Value 'Me.ComboBox1 = ThisWorkbook.Sheet5.Range("ExpCat").Value
I am trying to make a UDF that searches for a header, grabs everything under the header, and pulls it somewhere else. My UDF has three parameters:
1) Output_Range: the named range where the parameters will be pulled to 2) Header: the header to search for in order to copy the data underneath it 3) WorkbookName: the name of the workbook to search in
It looks like this:
VB: Function LoadParameters(Output_Range As Range, Header, WorkbookName As String) MyTimer = Timer 'Defining the variables. Dim HeaderCell, HeaderCellEnd, HeaderRange, Output_Range
I have some named ranges that refer to 5 pieces of data organized into a row. For example, the name MyNamedRange might refer to $C$5:$C$10.
I am trying to loop through each column and get the values in MyNamedRange, then change corresponding values in a different named range. However, when I try to use Offset to access the subsequent columns of MyNamedRange, it doesn't work. It only gets the value of the first column right, the rest return <EMPTY>.
How do I go about using named ranges instead of cell names(ie A4:A9)
Private Sub UserForm_Activate() Dim lngRow As Long Dim intIndex As Integer UserForm1.ComboBox1.Clear 'Clear combobox lngRow = 2 Do While Sheet1.Range("a" & lngRow).Value <> "" For intIndex = 0 To UserForm1.ComboBox1.ListCount - 1 If UserForm1.ComboBox1.List(intIndex) = Sheet1.Range("a" & lngRow).Value Then Goto NextRow End If Next intIndex UserForm1.ComboBox1.AddItem Sheet1.Range("a" & lngRow).Value NextRow: lngRow = lngRow + 1 Loop End Sub
I wanted to change "a" to the defined range "search"?
The '-1' allows for a heading at the top of the column. This works fine when the list in col. L has more than one entry under the heading. But with only one entry I get 'Runtime error 381 - Could not set the List property, Invalid property array index' and the debug highlights on
I'm creating a KPI spreadsheet which utilizes named ranges to allow for Dynamic charting. I've created the first data input sheet for one of the 10 areas being KPIed. The sheet has 60 named ranges in it.
The goal is to duplicate the existing sheet (Area 1A) 10 times and adjust the named ranges and formulas within the named ranges according to the sheet names.
Is there a way to accomplish this without having to manually recreate or edit every named range for each new sheet?
I want a sumIF function (based on three criteria) to fill the values of cells in a column so long as there are values in the cells in the column before that one. I was working with trying a loop, but have been shown a faster way is using the With function.
There are four named ranges that all exist on a separate sheet in the file: Crude, Location, Year and Volume. Based on the first three columns of the file I wish to have an output for the sum of volume based on crude, location and year.
Right now, my output simply returns the total sum of the "volume" range in each cell in the output column.
For example, if total sum of values in the volume column is 100 then my output column currently looks like:
I am having problems getting the code below to follow my intentions. I have 2 files. I have a temporary file that holds all the data that I need. I have a destination file that needs to have data copied into it. In the temp file, I have data for several dates and product types. What I intend to do is to do a vlookup in VBA to look for the date and the product type in the temp file and copy the appropriate data to the destination file. I have numerous named ranges both in my temp file and my destination file. For the code below, I wanted to make a loop to find the date in the temp file that is listed in the destination file. Once this is done, I wanted to find the product type in the temp file that is listed in the destination file. If both conditions exist, then copy a certain range from the temp file to the destination file. My intention is evident in the code, but I don’t think that I am putting in the correct “code format”.
(Using Office 2003 on XP Pro) I have two named ranges that I want to union into one big named range so that I can use the big named range in a validation table. Unfortunately the big range does not appear on the list of named range so I switched to VBA to try and lick this but really I was hoping a non-VBA solution exists. Exploring possible VBA solutions, here is what I have so far:
I'm trying to make my worksheet generate a bunch of named ranges whenever it is activated. However, I'm getting a "Not a valid name" error on the line in red. The value of r is a string, so I really don't see what the issue is. Another time, I got a object defined error, but I think I've declared everyhing too. That line is very similar to the line above, and tends to work once (the first time around the loop). After that, I get the errors I mentioned.
I have two named ranges, LV1 and LV2 and wish to select them for printing. If the ranges were fixed I would use - Range("A2:H4,A8:H10").Select - how do I do the equivalent using the named ranges in vba?
The worksheet contains 20 different datasets which are divided into separate 30 x 10 grids, all of which help comprise a larger 300 x 20 grid. I have defined each smaller grid/dataset as its own named range. Originally the entire dataset started in A1, but I am shifting it dataset down by 40 lines to create space to work at the top of my workbook.
I am wanting to create a data validation list in A1, then have cells A3:J32 populate with the named range I select in A1. However I also want this populated dataset at the top of the sheet to be a mirror -- not a copy.
Therefore once I have the data in my range available A3:J32, anything I manipulate would be mirrored in the original range in the lower portion of the workbook.
I am importing an external Sheet into my Excel workbook but it only imports the data not the named ranges. I need the named ranges to be imported and overwrite any existing range of same name.
In existing workbook Sheet I have a named range, ABC which is A1:E10 - in the Sheet I am importing the ABC range is A1:E12. So when I have done import I want named range ABC in my workbook to become A1:E12 (as per external Sheet).
This is the code that import data (but not named ranges)