Detecting CTRL Key Or ALT Is Pressed
Sep 29, 2013How could I detect if the CTRL (Control) or ALT key has been pressed. I want to execute a macro when either one is press over a given cell.
View 3 RepliesHow could I detect if the CTRL (Control) or ALT key has been pressed. I want to execute a macro when either one is press over a given cell.
View 3 RepliesI was thinking of how the Worksheet_Change(ByVal Target As Range) macro can be used to paste values instead of formula when the user uses Ctrl-C and Ctrl-V. Instead of assigning a macro to a command button for user to activate.
Suppose I have a worksheet where the range ("D7:D56") is where I would want the user to paste his values in it.
I have to factor in the possibility that these values have formulas attached to them, and that the user is not tech-savvy enough to know about the "paste special --> values" functionality of excel, and chooses to use the Ctrl-C, Ctrl-V method instead.
What then appears are ####### which might alarm the user.
Neither would we want the user to press a button (which we can assign the xlpastevalues macro as an alternative) as that adds an extra step for the user. There is also a chance the user might not use the button, or overlooked it.
Is it possible to use the Worksheet_Change(ByVal Target As Range) macro, or sth similar, to paste values instead of formula when user uses Ctrl-C and Ctrl-V?
how can I go about this?
View 9 Replies View RelatedIs there a way of detecting, when printing, that a cell is at the top of the page?
I am not talking about the automatic "Rows to repeat at top" option on Page Setup; I have programmatically suppressed repeating information in Column A but I want to repeat that information if the column is fed to a new page.
Would like to detect same value in 3 cells.
Q 16, R 16, S 16
If there is a same value appearing in two of the three cells.
I've written a macro to copy data from a series of columns on one sheet and past it on another sheet in a specific way. However, what I really want to do, is write the macro so it automatically detects what the last column is, either by defining a range consisting of the last column, or by writing "Last Column" in one of the cells of the column, and having the macro detect it.
Dim i As Variant
For i = 5 To 56
' What I want to do is have the second number be the last column, instead of 56.
Sheets("MASTER").Select
Selection. AutoFilter Field:=i, Criteria1:=">0", Operator:=xlAnd
Range("Basic_Data").Copy
Sheets(" Consolidate").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 4).Range("A1").Select
Sheets("MASTER").Select...........................
I'm trying to get a macro to run in my worksheet anytime someone presses the Enter key. I've been trying to use Private Sub Worksheet_Change(ByVal Target As Range) and getting extremely frustrated. I’ve tried a bunch of things and nothing seems to work. This is my latest that doesn’t work.
View 5 Replies View RelatedI would like to detect when the user uses the "DELETE" key and would like to run a macro at the same time.
how to detect it and run a macro in VBA.
I have Sheet2 containing Supplier data in 2 columns - SupplierTAxCode and SupplierName (unsorted)
Sheet1 contains the Expenses section.
In Sheet1, column E6 to E1000, after inputting each SupplierTAxCode and pressing the RIGHT ARROW key, I would like to automatically get the SupplierName in column F6 to F1000 - from the corresponding data in Sheet2
In the event that the input in any of the cells in E6 to E1000 does not exist in SupplierTAxCode in Sheet2, would it be possible at the same time, to change the background color of the adjacent cell (SupplierName) in column F6 to F1000 at the same time - as a reminder to add those to the Supplier data in Sheet2 at a later date.
I could use Index Match and Conditional Formatting, but am concerned about the file sizes.
Onkey is used to make something when a key is pressed. There is a instruction to make something when any key is pressed?
View 4 Replies View RelatedIn my company we have many spreadsheets with sections that contain formulas, which may be overwritten with "hard coding", manually entered constants, in certain situations.
Is there a way I can detect the differences between the two types of cells? I would like to setup conditional formatting that would highlight constants in a table that would generally only contains formulas.
It worked well at the time and continues to work well.
The problem I have is that I've copied it for use in a new workbook and for some reason it's not picking up email addresses and storing them in the string "stemails", so that when the email is created there are no addressees. Column BA does have email addresses in it however.
[Code] .....
Using Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) I can execute code when values in the cell change, but it can't check if the foreground or background color changes. What event can detect this? If no event can, is there any way at all?
Found this, I will look into this loop: Capturing cell color change in VBA
A1 : Style 998 45702B WRAP DRESS 1 0 0 0 1
Try to accomplish:
I would like to remove the "1" in between "Dress" and "0"
in other word remove integer from string but starting from right only.
B1 = should contain 1
I execute custom Insert and Delete macros whenever when the user has selected a single contiguous range of rows to insert or delete.
But I don't know how to detect if the user has selected multiple, non-contiguous rows. Is there a way to detect this situation, and if so, is there a way to "loop" through the individual selections?
I've been working on a visualizer for large data sets and I'm trying to create a flexible interface. What I am trying to do is populate a sheet with objects(rectangles, triangles, etc.) and linking them all to the same macro. The macro would detect what had clicked it and read the alternative text which would hold the command procedure for that object. I've seen how people detect cursor position but I have not come across anything to detect the object that was clicked. The code I've found (in another post) is as follows:
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Type POINTAPI
x As Long
y As Long
End Type
Sub CurosrXY_Pixels()
Dim lngStatus As Long
Dim typWhere As POINTAPI
lngStatus = GetCursorPos(typWhere)
MsgBox "x: " & typWhere.x & Chr(13) & "y: " & typWhere.y, vbInformation, "Pixels"
End Sub
This works but I can't figure out how to detect the object it clicked. I was hoping to use
ClickedObject = ActiveWindow.rangefrompoint(typeWhere.x, typeWhere.y)
Command = ClickedObject.AlternativeText
but all I get is errors.
I need to code a procedure which detects when a cell has changed color (I cannot assume where the cell is).
I thought I might be able to use the worksheet_change procedure, but this only 'reacts' when the cell contents change. Can anyone point me in the direction of the right procedure to implement.
I have a macro tht deletes sheets from my workbook. How do I check if these sheets exist before deleteing them? Thus so that
Worksheets("MySheetName").Delete
Does not generate an error if "MySheetName" doesnt exist?
I am working on a workbook in which you can click a button on an index page to create a new sheet in the workbook with the name "meeting" and the number meeting that it is. The new sheet is then added to the index page. I am looking for a way to detect when a sheet is deleted so I can update my index page accordingly. I need to be able to know when a meeting is deleted so I can rename all meetings after that meeting and then update my index.
View 7 Replies View RelatedI want a macro to assess whether there's a page break before column P, if so, remove it and continue, if not... continue.
View 7 Replies View Relatedi have tried using the letter M as a shortcut key (because it is to activate a "Move" function) but unfortunately it doesn't work. I gather from this that not all of the keys are available as shortcut keys presumably because they already have function.
Is there a way around this? and/or is there a list somewhere of the available shortcut keys?
the keyboard shortcut to switch between workbooks in the application seems to have stopped working on my boss' machine.
View 4 Replies View RelatedI need to be able to run a macro called "Daily_Fuel_Line_Save2" when the enter key is pressed in any cell in the range A10:F10, but I still need to be able to use the tab key between the individual cells and change values in this range before starting the macro.
I already have the following code on the sheet which I would also like to keep.
[Code] .....
I want to get number (going from 1 to 15 (for example)) when i click on commandbutton (on userform without textboxes, combos , etc, ..... except only one commandbutton)!
In other words, when i click on commandbutton, i want to get (on msgbox) number 1, then when i click again on commandbutton, i want to get number 2, then when i click on it third time, i want to get number three on msgbox window, and so on until i close userform!
how to make a code so that it captures the event of pressing any key of the keyboard and triggers a macro.
I tried using OnKey method but the problem with this is I am getting stick to any particular button whichever i specify in the onkey method wheareas I want to keep it general for any button in the keyboard.
Also if anyone can suggest how can I use OnKey method to use the "S" key to launch a macro.
Private Sub ValidarCampos()
Dim r As Long
Dim c As Long
Dim s As Worksheet
'Set s = Active.Worksheet( Name)
Dim Error As String
' Dim ws As Worksheet
Dim ValorMensaje As Long
'Turn off Screen refresh
Application. ScreenUpdating = False
'Use Cells(Row, Column) for range adddress
r = ActiveCell.Row
c = ActiveCell.Column ..................................
How can I simultaneously with this code put data from textboxes to Active sheet and sheet "Izpisi". So when the button Add(dodaj) is pressed the data goes to active sheet and sheet ("Izpisi") at the same time
I want to enable button on the Menu and Toolbar if User is selected entire row (only one row). If it is selected some Range or more than one Row, the button must be disabled. I'm using this to detect what is the user selection:
View 2 Replies View RelatedI have created a table with the values of each letter (A = 4, A- = 3.7, B+ = 3.3, through F)
I would like to have a points column which multiplies my letter grade (references a value from the table) by the units the grade is worth.
What function can I use to compare a letter grade with a value I've set.
Example:
Grade: B+
Units: 4
GPA Points Earned: = 3.3 * 4
I am trying to write a macro to paste the data that has been copied onto the clipboard into my worksheet. However I want to paste it in different ways depending on what data is there.
This is what I have so far:
Sub ImportTissue()
Sheets("Tissue").Select
If "dimensions of clipboard data are 5 cells by 5 cells" Then
Range("E11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
[Code] .........
How to detect a change in a spreadsheet, but how do i etermine on which cell the change happened?
Basically, I need something like this, if in the range of b1:b30 a cell is changed by the user, let say B??, then change or modify (via a subroutine) cell A??.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'
' detect which cell in the range b1:b30 changed
' then modify the cell to the right (or left) of the changed cell
'
End Sub