Changing A Selection On SelectionChange
Nov 11, 2008
I have a reference sheet that the only cell that should be accessed is in col A
Rather than protecting the sheet I have made it so that what ever cell is selected it changes to select the cell in A
however if the selection is made using the col, header (ie clicking the C) it falls over.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(ActiveCell, Range("A6:A1000")) Is Nothing Then 'makes sure A isn't already selected
x = ActiveCell.End(xlToLeft).Cells.Count
ActiveCell.Offset(0, -x).Select
Else
If Selection.Cells.Count > 1 Then ' fixes the problem of selecting a range that starts with an A
ActiveCell.Select
End If
End If
End Sub
View 9 Replies
ADVERTISEMENT
Jul 1, 2008
from the xlVBA help:
SelectionChange Event
Occurs when the selection changes on a worksheet.
Short and nice definition.
But when does a selection change?
Does the selection change when the selected range moves to another range?
Or does the selection change when its value changes?
Or both?
And how to deal with that?
View 9 Replies
View Related
May 28, 2008
time-to-time an unexpected eventcode appears in my worksheet modules
View 10 Replies
View Related
Mar 31, 2009
I have a SheetSelectionChange event that stores the Target.Row in a cell on the active worksheet.
View 15 Replies
View Related
May 11, 2009
I have code in my Worksheet_SelectionChange.
However it will not update until I physically click on any cell within the U33 to U38 range.
How do I tell Excel that I physically clicked on any of these cells? I have tried Activate..., blank and re-populate, select cell, select range... In VBA it does not think it is being clicked on.. it is just doing the code... when done I have to again manually/physically click on it.
View 9 Replies
View Related
Feb 12, 2014
I am trying to develop a worksheet that will adjust dates based on a selection from a drop down box. I can do basic formulas in excel
I am trying to get the drop down box in "Revisit Type" to include three selections ("Sanitation", "Spark", and "High Five"). Once the dropdown box is created I want to be able to make a selection and enter an initial visit date under "Initial Visit Date" then have the "Earliest Return Visit Date" and the "Latest Return Visit Date" automatically populated based on this information below:
Sanitation or Spark = 10-30 day window
High Five = 10-21 day window
I am at a loss . I have attached a sample of the workbook for reference.
View 3 Replies
View Related
Jan 28, 2013
Changing the data based on a drop down selection. My drop down list is based on the months I need the data (percentages for each person) to change depending on which month is chosen. So If I select Jan, the percentage fills in for each person. I've attached an example.
View 3 Replies
View Related
Jun 6, 2006
Found the wonderful code here at Ozgrid and would like to change the return to home selection.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("d4:Ad104"), Target) Is Nothing Then
Int_color = Target.Interior.ColorIndex
Select Case Int_color
Case xlNone
'Question, what does "xlNone" do?
Target.Interior.ColorIndex = 3
Target.Font.ColorIndex = 3
Target.Value = "true"
'Range("A1").Select - would like to change this to move the selection to
'the present row clicked, column c. If I click on G9 the selection returns
'to C9.
Case Else
Target.Interior.ColorIndex = xlNone
Target.Value = "false"
End Select
End If
End Sub
View 2 Replies
View Related
Dec 15, 2009
Attached is the file i am working with. The table spanning from A:AA5:16 contains hours worked per day of the week with respect to the Project chosen from the drop down menus in A7:16. Cells in the range of F,K,O,R,U,X,AA7:16 total those hours worked on a daily basis. The table below should sum the total hours worked per day according to the Project selected in A19 from the drop down menu, with respect to the Project(s) chosen in cell range A7:16. For example, if i am looking for total hours worked Monday on Project RSB i select "RSB" from the drop down menu in cell A19, i want cell F18:19 to be the sum of cells A7 and A9, with respect to the Project selected from cells A7:16. If I select "FRG" from the drop down in cell A19, i want cell F18:19 to reflect the sum of cells F8 and F10.
View 2 Replies
View Related
Apr 24, 2009
I have a list similar to the below:
#....|Name.... | Weighting %
1Artur Boruc 1
2Igor Tudor 5
3Alessandro Grandoni 3
4Gian Elia Amoretti 3
5Olivier Kapo 12
6Kim Källström 13
7Emiliano Bigica 13
8Julio Baldivieso 12
9Fabrizio Miccoli 13
10Peter Vougt 14
11Massimiliano Esposito 12
What I want to do is randomly select either number 1 to 11 (leftmost column OR the person it represents) but also make the selection based on the percentages in the rightmost column. To illustrate using the above example, Number 11 (Massimiliano Esposito) should have 12 times more chance of being randomly selected than Number 1 (Artur Boruc)...
I have used a formula such as
PHP
=INDEX(A$1:A$11,INT((RAND()*11)+1),1)
to randomly select a cell but how would I modify this to include cell weightings? Or is there a better formula?
An additional note I have is that the weighting for each person will always be changing, but will always be a percentage.
View 11 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
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
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
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
Sep 16, 2009
This may have been answered on here but can not seem to find it. My situation is I have values in A1,A2 & A3 that are like counter reading so the value is always changing. What I am looking to do is change the cell color if one of the values is over 500 from the other two values. Say A1 is 3000, A2 is 3250 and A3 is 3500. I would like the cell for A3 to change color.
View 2 Replies
View Related
Sep 9, 2007
Moving between different sheets changes the procedure window, which is a good thing, but can also can be error prone and annoying to search through several windows searching for the procedure or module currently working on. Is there a setting somewhere to prevent VBE from changing the current procedure window?
View 4 Replies
View Related
Mar 26, 2007
I'm using the following code in a worksheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
col = ActiveCell.Column
Range("output") = ActiveCell.Offset(0, -(col - 4)).Value
End Sub
In case it's not obvious, the macro places the value in the active row and 4th column of the worksheet into the range "output".
The problem is, the worksheet is large and somewhat slow to recalculate. This macro forces a recalc on any selection change, but i only need it to run when the row selection changes, not the column.
I'm sure there's a straightforward way to reprogram this.
View 7 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
May 24, 2007
If the selection (or any part of the selection) = bla bla bla
View 9 Replies
View Related
Jul 13, 2007
I have a code (pasted below) that copys a line of data from one workbook into another. Each time i run the code it enters the data on the next available line. This is all working ok however what I would really like to do is when i run the code have it pop up a selection box asking me which sheet i would like to copy from. The reason i need this is that the sheet that gives the data isn't always named the same although the format is exactly the same every time. In this example the data sheet is "copy of NewProductForm), this name may change and i may also have other different active workbooks open at the same time and I don't want the macro to get data from them.
Code :
Sub GetData()
Windows("Copy of NewProductForm.xls").Activate
Rows("48:48").Select
Selection.Copy
Windows("Book2.xls").Activate
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Copy of NewProductForm.xls").Activate
Application.CutCopyMode = False
Range("A41:AH41").Select
Windows("Book2.xls").Activate
End Sub
View 9 Replies
View Related
Dec 22, 2006
I am trying to format a range of cells based on a user selection. The user may select 8 rows (rows 20 - 27) or the might just select A20 to A27 or the may select A20 to C27 on all of the occasions I would like to find the 1st row and the last row of a selection. I have found the command
x = ActiveWindow.RangeSelection.Address
which I could try and extract the row numbers, but is there an easier way?
View 7 Replies
View Related
Jan 24, 2007
I want to program a macro that reads out the min row number and max row number of a selection.
Lets say a user selected the Range A1:D4.
After executing the macro I want the following output:
The min row number of the selection is: 1
The max row number of the selction is: 4
View 9 Replies
View Related
Mar 18, 2014
For a specific equation to work I need to know the distance whenever the acceleration is maximum.
The last part is a piece of cake, using MAX I get the desired results.
However, returning the distance is difficult.
What I'd like to do is return the value of the cell to the right of the maximum acceleration.
Using
=ADDRESS(MATCH(MAX(K2:K754);K2:K754;0);COLUMN(K2:K754))
I got the address of MAX, but that's about as far as I get.
View 9 Replies
View Related
Jul 17, 2009
I have a list of 4 customers and their individual revenue, which is summed up in cell E12.
What needs to be done to make Excel only sum revenue of say customer A and D in cell 12 upon selection of these through standard filter (see attached sample)?
View 2 Replies
View Related
Apr 9, 2013
I've attached a sheet. In this sheet I would like to print the selection....C9:17 and BL9:BW17. I would like to print it onto a PDF and I would like to expand it so it is very visible. Actually, it doesn't need to be PDF. If I could just print this selection and make it visible that would work. I had a problem using print selection because the columns are separated. I also tried fit to page but that makes it too small.Mod's note: file attachment removed at OP's request
View 2 Replies
View Related
Oct 22, 2008
I'm having a problem summing after running arrays to analyse data. I have a list of four possible outcomes and I need sum up the totals, but sometimes there are no results, so there is #DIV/0 in the list I need to find the total for.
is there some code or some kind of formatting that would give me a total even if #DIV/0 is in the list?
View 3 Replies
View Related
Nov 2, 2008
I've currently written the following code to make sure exactly 2 single cell selections are made. But now, I want to extend this code to make sure only cells from rows 5 & 7 are selected and the cells are in the same column.
View 2 Replies
View Related
Dec 18, 2008
I want to create a macro that will allow me to highlight a column and have the macro Trim every cell with text in the column, preferably putting the results over the original text. The column in question has text in every cell, until the column ends.
(That is, there are no numbers and no blanks until the data ends altogether.) I do not want to remove internal spaces in the text, just the leading and trailing ones.
I am sure this is fairly simple, but I'm not sure how to get it to look at every cell and then terminate properly.
View 8 Replies
View Related
Jun 16, 2009
It is actually a form - much like Access. I have protected it so it can't be changed. They can click on a particular cell, but as soon as they try to enter anything it gives them a message and entry is not allowed.
Is it possible to even prevent them from selecting an individual cell, i.e., restricting them to only clicking the control buttons ? I realize this is a spreadsheet, other products would probably have worked better, etc., however it's kind of like the last minor hurdle before releasing it for general use. The world certainly will not stop if I can't - just thought I would check with the expers.
View 4 Replies
View Related