Set Range Variable To RefEdit Control
Dec 3, 2007
I'm trying to set up a userform with a refEdit box that allows the user to select a cell range. I then need to assign that cell range to a range variable so the macro can use it. I'm having a problem reconciling the assigned string variable that refEdit returns and the range variable that I need.
So what I'm trying to say is that I can assign the range fine through the Userform, and I can see through the debugging screen that mySampleVariable (dim as a variant) holds a range value of 'Access Dump'!$A$8 (the correct range), but when I try to
Dim myRange As Range
Set myRange = mySampleVariable
The code bugs out because it apparently can't assign a string value to a range variable.
View 4 Replies
ADVERTISEMENT
Sep 7, 2007
I have built a user form that amongst it's other functions displays the results from three cells on one worksheet.
The values in these cells need to be pasted in three cells on a different worksheet (cells are selected by user using a "RefEdit" field on the form.
The VBA help files offer a single example of the paste special method (I've proven I can paste to the celss but of course that pastes the formula rather than the value!) that shows it operating on a single worksheet as follows:
With Worksheets("Sheet1")
.Range("C1:C5").Copy
.Range("D1:D5").PasteSpecial _
Operation:=xlPasteSpecialOperationAdd
End With
So, simple question...
How can I use the Paste Special method to paste the values of the cells in cells specified by the user?
View 5 Replies
View Related
Jul 8, 2009
I am using a refEdit control on a userform to get a range from the user (they use the refEdit control to click on the desired range). My problem is that the user typically has 3 or 4 different workbooks open and if one of them is maximized withing Excel, the user is unable to get to them to select the range (only the maximized workbook is displayed and usable). Is there a way around this?
View 4 Replies
View Related
Jan 23, 2007
I would like to use the RefEdit control in a worksheet in order to select a range of cells and pass its address to a different cell without code.
I thought of using the LinkedCell property of the RefEdit as I used it for a ComboBox.
View 9 Replies
View Related
Feb 23, 2007
I am trying to implement a simple userform using the RefEdit control.
So I have the RefEdit control and an Ok (which has code attached to it) and a Cancel commandbutton.
For some reason, I can't get the focus on the RefEdit control (i.e. when I activate the form, I have to actually click in the RefEdit box before it gets the cursor). Which property sets the focus in this control?
Right now I have the Ok button Default property set to True.
I have a commandbutton on the spreadsheet that activates the userform.
View 9 Replies
View Related
May 24, 2007
I'm finding that my add-ins that worked perfectly on Excel 2003 are not functioning on Excel 2007. One of the main issues seems to be loading any UserForms that use the RefEdit control. I get a message saying:
--------------------------------------------------
Run-time error '459':
Object or class does not support the set of events
--------------------------------------------------
View 5 Replies
View Related
Oct 27, 2008
I have a userform with a 3 refedit controls. Each needs to capture a range from a different workbook (already open - only not active).
Is it possible to configure the refedit to capture a range from another workbook (either thru window menu or ALT+TAB)?
I notice that InputBox type:=8 allows it - I'm a little suprised that default refedit doesn't.
View 9 Replies
View Related
Feb 27, 2013
I have a refedit box in a userform wherin i will be selecting a range and thus getting a value say "$A$1:$A$2"
Now what i need is that it should seperate the value as follows so that they can be used in another place
starting column to a variable x.
starting row to a variable y
similarly
ending column to a variable p
ending row to variable q
Looking for code that if i select more than 1 column in the refedit it should tell me to select a single column and not more.
View 2 Replies
View Related
Dec 17, 2013
I have a HUGE dataset (more than 1 million rows). I'm trying to find the optimum cell range size - 10 rows, 100 rows, 682 rows, whatever - for a SUM formula. (The formula would be in every row, looking down at the next n rows).
Is it possible to control the SUM cell range specified in a formula in cell (X) with a value in cell (Y)? In other words, the SUM formula in cell (X) would somehow refer to cell (Y) to determine the SUM cell range.
Ideally, I would like to then use Solver to find the optimal value for cell (Y).
Is this possible with just formulas? Or is VBA required?
View 5 Replies
View Related
May 9, 2014
Why this doesn't work?
I get the error message: Invalid Next control variable reference
And it highlights the i in 'Next i'
[Code] .....
View 3 Replies
View Related
Jan 26, 2007
I have several checkboxs in an excel sheet, that if one is checked i would like it to make a change to a variable in a macro that will run when saving a file.
for an example:
if checked:
Checkbox1 = NCE1
Checkbox2 = NCE2
Checkbox3 = NCE3
Checkbox4 = NCE4
Checkbox5 = NCE5
I have a bit of code that is like this....
ActiveWorkbook.SaveAs ("\marketing2PartageNonconforms" & sF1 & " - CO" & sF2 & " - FC" & sF3 & ".xls")
I would like sF1 to change depending on which checkbox is checked. so if checkbox1 is checked, than sF1 = NCE1 .
View 9 Replies
View Related
Mar 22, 2008
How do I reference a spin button from a variable that I set.
e.g
Dim objSpn As Object
Dim y As Integer
Set objSpn = ActiveSheet.Shapes("spnWCDate")
y = objSpn.Value
This doesn't work, but hope it explains what I want. It's so I dont have to write the whole object name each time I reference it.
ADDED: I've just noticed that this doesn't work even i do reference the object with the full name. I copied this from a forms spin control that I was using, why can't i store the value of the spin button in a variable?
View 4 Replies
View Related
Jul 16, 2013
I have written the following VBA Script but am getting an error message saying -> "Compile Error. Invalid Next control variable reference".
Code:
Sub Form1() 'Change Yes/No
Dim bottomT1 As Integer
bottomT1 = Sheets("Data Sheet").Range("T" & Rows.Count).End(xlUp).Row
Dim bottomP2 As Integer
bottomP2 = Sheets("Follow-Up").Range("P" & Rows.Count).End(xlUp).Row
Dim bottomO2 As Integer
bottomO2 = Sheets("Follow-Up").Range("O" & Rows.Count).End(xlUp).Row
[code].....
View 5 Replies
View Related
Jun 13, 2007
When creating a userform at run-time, I can add list boxes, command buttons and all the other controls to a userform with code like this
Set newButton = newForm.Controls.Add("forms.commandbutton.1")
Run-time error '-2147221005 (-7FFBFE0D)':
Could not complete the operation due to error 800401F3.
when I try this line
Set button0 = newForm.Controls.Add("forms.commandbutton.1")
View 9 Replies
View Related
Jul 9, 2009
I sent the attached to a user who said it wouldn't run when the 'Draw Venn' button is click - some sort of RefEdit compile error. I can't replicate the error and can't find what's causing the error.
I had started using RefEdit control but couldn't get it to work the way I wanted, so just went with input boxes. I run this on XL07 SP2, other user has XL03 - not sure if that's relevant to the error they're getting.
View 4 Replies
View Related
Aug 1, 2008
I have a userform where users select a range with a REFEDIT control say:
'Sheet1'!$G$38:$AA$39
I need some VBA code to break this down to the following variables:
a variable giving me the first column i.e. "G"
a variable giving me the last column i.e. "AA"
a variable giving me the first row i.e. "38"
a variable giving me the second row i.e. "39"
If it's easy for you, I also need an error handler to ensure that only two consecutive rows are selected by the user.
View 9 Replies
View Related
Dec 4, 2008
how to work with RefEdit tool within a userform!
eg: say I use RefEdit to select a range and I want that range to be in Bold.
Just give me a small code using RefEdit to perform the above action. I hope then I can use it in a larger way.
View 20 Replies
View Related
Nov 10, 2006
Say you define a public range variable called Inputworksheet and you set it to refer to the worksheet called Inputworksheet. You have a separate string variable with the value Inputworksheet. How do you get this string variable value to call/control the range variable Inputworksheet?
I am getting an excel worksheet value from a lookup function that corresponds to the name of a VBA range variable. Once I have this worksheet value, I would like to use the range variable that has the same name as the worksheet value.
View 5 Replies
View Related
Apr 4, 2008
I am trying to autofill dynamic ranges that have column variables (d) and row variables (x)... I am having a hard time with the syntax on this
View 9 Replies
View Related
May 3, 2012
I have several non-modal userforms in my App, some of them have date-fields that require manual entry typing of dd/mm/yy etc (No single userform has more than one date-box in it, this I think may be pivotally useful)
Now the Userform 'Calendar' that is built on the class of the same (cCalendar) name, has the write value line 'ActiveCell.value = theCal.value'
I'm looking to change this to refer to the correct userform.Textbox value, depending on which form is open.
I would imagine I could simply have a global string, whose value is set (or re-set) whenever a Userform is initialized (some sort of 'ActiveUF.value = Me.Name), where I get lost is referring to the components by name, so as to have a case statement by where I go:
Code:
Private Sub theCal_AfterUpdate()
Select Case ActiveUF
Case "AddForm"
application.vbe.components("AddForm").controls("AddFormDatePicker").value = theCal.value
Case "EditForm"
'.... etc
end select
end sub
better way of doing this (instead of passing around the userform name as a variable) - or proper syntax for referring to controls outside of the 'active' userform (but an open userform nonetheless)?
Every time I have to do this particular thing with userforms, I completely forget how, and the object browser always leads me on an infinite loop of Application.vbe.activevbproject.vbcomponents.vbe.active....
PS - there may be one slight complication to the process - one of the forms, has a 2-tab page in it, each page having similar (but named differently) fields. So I may need to be able to throw in 'Activepage' or whatnot
View 5 Replies
View Related
Mar 11, 2008
I am using a variable named " Totals" as a range type to refference the range in a formula. It works the way I have it.
Dim Totals As Range
Set Totals = [U37: AE37]
Now instead of the absolute refference, I would like to change the row refference by an offset of my current row, using a formula with a varriable. The columns stay the same.
View 3 Replies
View Related
Jan 16, 2010
Hi all im having a tough time trying to figure out a way to select a range (which will be the entire row )based on a condition that will be data selected from a combobox and display that range in a userform with spreadsheet contol 9
what i have so far is a worksheet with all the data.
i have a combobox on a userform that is prefilled with data from a specific column
every thing is working except when i select the entire row how do i change that to a range that i can use in the spreadsheet control 9 that is added to the userform.
View 11 Replies
View Related
Sep 12, 2007
I would like to define the range of cells in the sum with a number in another cell. Say I want to sum the past 10 years, I would like the sum definition to be controlled by another cell that includes the number 10.
If I want B1 to be the sum of A1:A10, B2 to be the sum of A2:A11, etc., I would like to be able to control the range of the sum with say, C1, which in this case would contain the number 10.
This would allow me to easily change the range of data I am summing: if I changed C2 to 15, B2 would give me the sum of A1:A15 for example.
View 9 Replies
View Related
Sep 4, 2009
I have a workbook with 20 sheets, including a control sheet 'Validation Table'. By setting the required Background/Font in a cell named hdrDefault on sheet VT, I want to click a button on VT to invoke a macro to visit each sheet and set the named Header range, hdrxxx, to the same Background/Font. Originally had the code in a Private Sub linked to a button event, but this can't break out of the worksheet so have moved the Sub into a Module, and calling from the click event:
Event:
View 3 Replies
View Related
Jun 29, 2012
I have sheet where I need to restrict access to a select group of individuals. I have a formula in a select case statement that runs from the workbook_open event and have hard coded the names of the individuals who can access the file. If they are not on the list, they are prompted for a password. This works OK, but I have sheet that is hidden and want to maintain the list of users there and update the code to loop through the values in a named range. I have a snippet of the current code below.
Code:
Select Case function_name
Case Is = "user1"
Run "enable_access_code"
Case Is = "user2"
Run "enable_access_code"
Case Is = "user3"
Run "enable_access_code"
Case Else
' User not authorized or opened while not on company network
' Prompt for project password
form_Password.Show
End Select
View 2 Replies
View Related
Dec 6, 2006
I have a defined range in my workbook which I have not been able to delete (I think it got there through some malware because I didn't create it!)
The main annoyance is that the name refers to another workbook (to which I don't have access) and to a non-existent range therein (resulting in a #REF! error) - so I get the unwanted Update Links message each time I open the workbook. I have created my own workbook with the same name as the workbook referred to by the name, hoping that I may gain some level of control over this gremlin, but to no avail.
The name is "Flow" immediately followed by a thin-lined empty square (like the ANSI character 042 formatted using Wingdings2 font). It could be a line-feed character.
Whatever it is, I have not been able to delete this range name - either directly through the Insert / Name / Define / Delete commands or by using VBA. Using the menu commands I can select the name, edit it (even add a valid cell reference to the workbook name), and click Add - but that just adds a new name "Flow" without the control character and the original name remains! The original name also remains if I select the name and click Delete.
View 6 Replies
View Related
Jan 11, 2008
the macro simply copies a master sheet, then re-organizes/re-sorts the raw data in the new sheet. At the end, I'm trying to set a print range to 1 page wide and inifinity pages long, figure out where the end of the fourth page is, then reset the print range to accommodate four pages. In case it matters, the macro starts with a form that allows the user to input a company ticker and name used in output.
The problem is that when I use the debugging step function (very tedious), it works perfectly. But when I run it normally, it locks up for about 30 seconds when setting the print range to 1 page wide, and cuts off the print range vertically at just over 2 pages tall. Brief explanation of a couple variables:
ColLetter is a function as follows:
Function ColLetter(ColNumber As Integer) As String
ColLetter = Left(Cells(1, ColNumber).Address(False, False), 1 - (ColNumber > 26))
End Function
ActiveSheet.PageSetup.PrintArea = "$A$1:$" & ColLetter(j + 3) & a + 7 .............................
View 2 Replies
View Related
Aug 8, 2008
I want a control to select a range in a userform I'm creating.
I wonder if we can use the same type of control the wizards use, where you click on the right and choose the range? Alternatively, what's the best option?
View 9 Replies
View Related
Jan 10, 2012
creating 2 fields in my userform that the user can input 2 dates that would serve as the range to set the autofilter. So user inputs field1 = 11/01/2011 and then field2 = 01/31/2012.
I was previously using a month range in my userform, populating from the known months and allowing the user to select a range. Since our data is now spanning a new year, this is no longer possible as I cannot make the combobox range go from 11 - 1 (November to January)
VBA Userform - select months & Months between - Code Included
View 1 Replies
View Related
Feb 19, 2010
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?
View 6 Replies
View Related