Multiple Cell Selection In VBA
Aug 21, 2013
I am putting together an order expediting sheet.
I get the code to refer to single cells, but cannot get it to refer to multiple cells in the same column.
The code i am using is:
Private Sub CommandButton1_Click()
If Sheets("Sheet1").Range("E6") > Sheets("Sheet1").Range("B2") + 3 Then Sheets("Sheet1").Range("F6") = "YES"
If Sheets("Sheet1").Range("G6") = "YES" Then Sheets("Sheet1").Range("F6").Clear
If Sheets("Sheet1").Range("F6") = "YES" Then Range("F6").Interior.Color = vbRed
End Sub
I need to have the ranges E6, F6, G6 to refer to E6 - E10000, F6 - F10000, G6 - G10000
View 5 Replies
ADVERTISEMENT
May 13, 2014
I have a spreadsheet where I've disallowed selection of multiple cells using the code in the 2nd box below, but is there a way to override this protection to allow selection of a named range? My reason for doing so is to open this workbook as read only from code in another workbook and copy the entire table. My code for doing that works ok (I frequently use it in other workbooks) but, in this case, my need to disallow selection of multiple cells in this particular worksheet is tripping me up.
This is the code I'm using to try and pull the data into another workbook:
Code:
Workbooks.Open Filename:=ThisWorkbook.Path & "RSL-Jobs-Register.xls", ReadOnly:=True
Application.GoTo Reference:="JobsTable"
Selection.Copy
and this is the code I have in RSL-Jobs-Register.xls which is preventing me from selecting the (dynamic) named range called "JobsTable".
Code:
''' I'm thinking I could have something here like (in plain English) "If selected range "JobsTable" Then"
''' (apply the code below) but I'm not sure of the code
If Selection.Cells.Count > 1 Then
MsgBox "Sorry, operations on multiple selections aren't allowed here", vbCritical
ActiveCell.Select
Exit Sub
End If
The formula for the dynamic named range called "JobsTable":
=OFFSET(Jobs!$A$2,1,0,COUNTA(Jobs!$A:$A)-2,11)
View 1 Replies
View Related
Oct 3, 2006
I tried very hard to design a leave roster for user to mark their leave application. The criteria are as follows:
1. 4 applications per date
2. a region of worksheet (i.e. "A2 to H20) will be defined for users to "click" on the cells (within the defined region) to mark their application.
3. once a cell is clicked (i.e. marked), it cannot be altered.
4. each click will automatically increase the total by 1.
I got the following code to deal with the situation but user can still click on any cell outside the region (in fact I fail to define the region).
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim m
ad = Mid(ActiveCell.Address, 2, 1)
m = Range(ad & 24).Value 'here a formula "CountA(A2,A20)" will be place in the cell (24, c).......................
View 2 Replies
View Related
May 4, 2007
I'm trying to build an investment calculator. Tried searching "calculator" as keyword but return nothing similiar.
There are eight cell : [ A ][ B ][ C ][ D ][ E ][ F ][ G ][h]
[ H ] is price of the leverage
[A] is X balance
[b] is X lot size
[C] is X amount of money use to get x lot
[D] is X percentage of money use to get x lot
[E] is X point gain
[f] is X money gain
[G] is balance + money gain
Ignore the formulae for leverage to determine 1 lot price. Take 1 lot = 250.
What I'm looking for is when I enter any value at cell B, C or D, it will automatically calculate the value for either B, C or D cell.
Let say, the balance is 10000.
If I enter 2 at cell B. Then, it will calculate the value for cell C & D.
If I enter 750 at cell C, then it will calculate value for cell B & D.
If I enter 25 at cell D, it will calculate value for cell B & C.
how to use OR Selection in excel.
View 9 Replies
View Related
Feb 21, 2009
The code below lets me select more than one item in a column 14 dropdown and put them in the cell.
I am trying to let another column have the same properties. This time it is column 17. I tried adding another line but it doesn't work. Can anyone help with the code.
View 6 Replies
View Related
Feb 16, 2009
In one of the worksheet. I have list of questions in column A.
In column B I want to have the following 3 checkbox
1> YES
2> NO
3> Not sure.
Based on the question, user selectts one of the check box.
User should not be able to select multiple checkbox. i.e. User can select only 1 out 3 possible options.
View 9 Replies
View Related
May 28, 2005
I want to copy a selection of cells and paste them into a row on another
sheet.
An example would be to copy:
Sheets("Sheet1").Range("T5,C7:T9,T13,C15:T17,T19,C21:T23")
and put it into A4:F4 on Sheet2
I know I can do it one cell at a time but I was hoping that I could speed
things up and do it all in one go as the macro will be quite long.
View 9 Replies
View Related
Dec 19, 2013
I am trying to create a simple order entry worksheet. In cell M1 I need a dropdown box that lets the user select which options go on the product. You can have multiple options. The list of options is contained in column A of the Options worksheet. Depending on which options are selected, I want to put a 1 in column B of the Options worksheet. how to do this or have a sample workbook that I can look at.
View 1 Replies
View Related
Dec 6, 2012
There are multiple training sessions that will be rolling out in Q1 13 and my manager needs a way to track which empolyees have been to which training sessions. Easy enough. He wants something extremely clean looking, but obviously efficient. What he described to me (his vision) is to have the training sessions listed into columns with drop down under each that contain every employee's name. So when a training session is held, he can easily click the drop down beneath the session title and select multiple persons that were in attendance. Right now I just have all the employees listed in column A and all the training sessions listed across the top and anticipated just putting a "x" in the box for the session that each person attends. This will accomplish exactly what he's looking for, but if what he's describing is remotely possible I would like to do that.
View 2 Replies
View Related
Oct 25, 2010
I have a userform where I want the user to be able to select multiple options, but am having a bit of a problem finding the best way to do this. If I use a combobox, I don't appear to be able to allow multiple selections, but if I use a listbox I don't appear to be able to implement a dropdown facility. I would prefer to have a single line sized box on my form, but doing this with a listbox would probably be confusing for the user as it is not very easy to see what has been selected.
View 11 Replies
View Related
Sep 3, 2009
I want to do is randomly pull from a field of data, MINUS any cells that do not meet the criteria in other columns. So if column A is my target column for the random selection (containing 10 unique entries), and column B has 10 repeating colors, and column C has 10 repeating animals, what can I use to perhaps create this effect: A random pull from column A, but only from rows in which column B says red and column C says cat? (The pull being 1, 4, 7, or 9 in the below example, of course.)
Data (this example is also attached in an excel doc):
One Red Cat
Two White Dog
Three Blue Horse
Four Red Cat
Five White Cat
Six Blue Cat
Seven Red Cat
Eight Red Dog
Nine Red Cat
Ten Red Horse
I have tried variations on IF and INDEX to no avail. Perhaps something with SUMPRODUCT?
View 3 Replies
View Related
Oct 26, 2011
I want to filter a list. Within the filter I want to copy a selection of cells and hard copy the formula in those cells (copy paste special values). It is possible to selected the cell and copy them but one cannot paste on a filtered range. The error message I get is "The command cannot be used on multiple selection".
View 2 Replies
View Related
Apr 24, 2013
I have an excel sheet where I can enter a text into A4, when this is valid a checkbox1 will appear if there is no value then the checkbox is invisible.
I have used a macro 'worksheet selection change' to do this but unfortunately I can only use this once in a sheet. I need to do this for upto 10 checkboxs that corrospond sequentially with text starting at A4 for checkbox1, A5 for checkbox2 etc....
The routine I have used for one check box is below. Can this be changed for multiple checkboxes?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A4") = isblank Then
CheckBox1.Visible = False
Else
CheckBox1.Visible = True
End If
End Sub
View 7 Replies
View Related
May 24, 2006
below is an excel file with a UserForm.
The goal here is to select the worksheets in one list box and transfer it to another. Multiple Selection is allowed. I am having 2 question i am struggling with.
Question 1 -
When passing the sheet names from List Box 1 to List Box 2 (using Add button) i would like the selected items of List Box 1 to be deleted after transfer. I thought i could access this using the command below but it does not work properly -> error message.
UF_PI_LINK_1.LB_SheetList.RemoveItem UF_PI_LINK_1.LB_SheetList.List(i)
Question 2 -
When the user is done the ListBox 2 need to be stored. When I save then close my workbook and then reopen it, i would like to be able to access the selection that the user has made before closing the worksheet. How can I store the content of ListBox 2 to achieve such a result. I guess i could use a use a hidden Worksheet where i could store the selection into some cells but i would like to know if there is a pure VB solution.
View 3 Replies
View Related
Feb 9, 2013
So I have a quote format with various different products:
B1 to B10 Contains a vlookup with stock codes from another page. C1 TO C20 Contains drop boxes with various different stock items. Some of the stock items are available in singular form and others are in kits. I.e C1 could contain whats in C2. I want to be able to select C1 and have the sheet automatically pull up c2. But I dont want to loose any data that is in c2, in other words I still want to be able to manually select C2.
View 5 Replies
View Related
Oct 17, 2013
I have researched and used some code that allows the user to select mutliple items from a list. This is using the Data Validation tool with a list and some code in the relavent sheet. It all works well and as described.
However, when I lock the Worksheet, the multi selection no longer works. Selection cells are ofcourse unlocked when sheet is protected.
I have also trialed unlocking the whole row that the multi selection exists in, no effect.
My understanding of this code is at about 50%.
Is there a way of being able to lock the sheet and retain this ability of multi selection. Maybe there is some other code I could refer too?
Code:
' Developed by Contextures Inc.
' www.contextures.com
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
[Code].....
View 1 Replies
View Related
Jan 22, 2008
I need to populate a worksheet's rows with values from 2 comboboxes and a listbox which can have multiply selected items. After finding the row's last free cell, I have the listbox values properly populating correct column. However, I not sure how to get the corresponding combobox values assigned to the appropriate columns.
View 2 Replies
View Related
Apr 10, 2013
I have 5 cities and each city has a set of data in separate tabs. Right now i have data pulled for all 5 cities in a single sheet but its too cramped up..
I want to use a drop down list (data validation) and if any of the 5 cities are selected in the drop down, the data from that particular city (tab) should be pulled up. This way my sheet size will be reduced 5 time which will look good.
A common v lookup wont work because the data has to be pulled from 5 different tabs for 5 different cities.
View 2 Replies
View Related
Jun 30, 2014
I have created a Data Validation list in one of my spreadsheets which works fine. The list itself has no duplicates which is fine but when I select my entries in the other spreadsheet, I want to make sure they cannot select the same value twice.
I tried selecting "List" in data validation and using an AND with COUNTIF but it doesn't work.
=AND(Employees, countif($A$1:$A$20,A1)=1)
View 2 Replies
View Related
Feb 6, 2013
I have two pieces of code that perform virtually identical functions on different sets of data.Basically, the code deletes rows of data based on a selection in a listbox. One code works perfect, the other has an issue.
The Issue:
When I select a single row for deletion, or multiple contiguous rows, everything works fine. It is when multiple Non-Contiguous rows are selected that the problem occurs. I get a "Delete Method of Range Class" error.
The data for the code that doesn't work is in a defined TABLE, the date for the code that does work isn't. So I assume this is where the problem lies.
I converted the data for the code that did not work from a table to a range, and everything works fine. However, I would really prefer that this data remain a table. There is consistently going to be rows added and deleted, and a table will take those adjustments into account, whereas a named range shrinks each time I delete a row, and doesn't grow as I add rows.Here is the code that works:
VB:
'Delete Selected Offers
Else
For r = 0 To ListBox1.ListCount - 1 [code].....
View 6 Replies
View Related
Jun 1, 2011
What I am looking to do is this... (using Excel 2007)
I need to have more dependent lists based on the selection in Column A. (My column B is already set up and works perfectly using INDIRECT)
For example:
Column F would be a dependent list of colors based on the sales rep chosen in Column A
Column I would be a dependent list of managers based on the sales rep chosen in Column A
Column M would be a dependent list of part numbers based on the rep chosen in column A
without using VBA? (If I HAD to - okay, the other person maintaining the sheet would be lost....) I haven't been able to find anything close to what I want to do online - maybe I am just not using the correct terms.
View 4 Replies
View Related
Sep 20, 2013
I am currently trying to make a digital time card for my place of employment. I has an odd set up and odd date ranges. The pay period starts on the 21st of each month and ends on the 20th of the next month.
The time cards have 5 columns for each week starting on Mondays going to Sunday (also weird its not Saturday to Sunday) What I was hoping to accomplish was being able to select the starting month of your choice for pay period and have multiple cells update the week date range.
Date
Date
Date
Date
Date
**Here would be the drop down month select.
Sept 21 - Sept 22
Sept 23 - Sept 29
Sept 30 - Oct 6
Oct 7 - Oct 13
Oct 14 -Oct 20
View 2 Replies
View Related
Jun 3, 2013
If a user selects certain options from a drop down list created by cell verification (from list), is it possible to display an input box and have the resulting input populate on another worksheet in the workbook? I have an attendance template I'm working with and if a user selects OT (Over Time) then a input box is displayed prompting for how many hours. The overtime is then tracked on another worksheet.
View 1 Replies
View Related
May 31, 2012
I have a workbook with two sheets. The idea behind the workbook is an Interview Guide to be used just before an Interview. For now my problem is this.
Sheet 2 "Competencies" is just data. It stores competencies with their associated definitions and questions.
Sheet 1 "Control Page" is the sheet where the questions will eventually go. The user (Interviewer) will input data on the first two pages which will include name of candidate, date of interview etc. but they will also select 5 Competencies from the already existing drop down menus on page two. From there as the selections are made I wish for a code to copy the corresponding definition on sheet 'Competencies" to cells lower down in sheet "Control page".
I don't see a place to upload a file as I have a sample of the sheet ready to go.
View 2 Replies
View Related
Jan 30, 2007
I have attached a portion of an excel file I am using at the moment. What I require is a piece of VBA code which will allow me to copy selected data based on a combo box selection. What needs to happen is this :-
If the selection in the "Index" worksheet combo box related to "Month" in cell G19 is for instance "December", I would like the macro to compare this cell value to the cell values in cells C96, C124, C152, C180, C209, C236, C263 and C290 in the "Tech Services" worksheet and where the values match.......copy the commentary (Range C126:Z147 in December's case) to the range C34:Z55.
View 9 Replies
View Related
Jan 24, 2013
I would like to know if there is a way to expand the selection of cells from the current cell you are on to the very bottom cell available in the spreadsheet.
For example, I want to apply a formula from A12 - the very last A cell row in the spreadsheet.
View 1 Replies
View Related
Jul 28, 2009
I would like to format cells with a currency based on a value selected at the top of my worksheet. Cell C3 is a drop down of currencies. And I would like cells range E11:E200 to format in whatever currency selected in cell C3.
View 9 Replies
View Related
Oct 10, 2007
I have an embedded chart on my worksheet.I can select a cell behind the chart using the keyboard arrow keys.Is there a way of doing this using a mouse click,so that I know which cell i am pointing to/choosing?
View 4 Replies
View Related
Apr 4, 2013
I am working on a project where user has to select an item from a listbox, however there is a condition that if user select an item, other items of listbox should be disabled so that he/she can not select any other item.
Is there any way to do that as I tried
VB : Listbox.enabled = False
and
VB : Listbox.locket = True
in Listbox - Click/Change but no desirable results got.
View 1 Replies
View Related
Jul 20, 2007
I want to have a drop down list in a cell so that the value in the cell can be only selected from two columns of data. Additionally once the data from the first column has been selected I want to be able to limit the inputs the user can select from in the second column.
e.g. In cell C115 I want to have the value BDS05.
I want to be able to select the value BDS from a drop down list of values and once that value has been selected I want to be able select 05 from a list of values from 01 to 14
If I select BCS as the first value then I want the second set of values to be limited to 01 to 02 etc.
I have read about combo boxes and list boxes and I'm a bit confused about the best way to achieve this (or even if I can).
View 6 Replies
View Related