ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reading the keyboard in VBA (https://www.excelbanter.com/excel-programming/418689-reading-keyboard-vba.html)

dwinmac

Reading the keyboard in VBA
 
Can someone show me how to code the conditional statement shown in the
comments below i.e. how to put the "x" in the cell only if the SHIFT ( or
ctrl or alt)key is selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
RowPos = Target.Row
ColPos = 3
' If Shift Key selected then
' Put an "x" in cell row = RowPos and Column = ColPos
ThisWorkbook.ActiveSheet.Cells(RowPos, ColPos) = "x"
'End If
End Sub

ShaneDevenshire

Reading the keyboard in VBA
 
Hi,

Is this code you got from somewhere or a guess on how it might look? I
think it would be better is you explained exactly what you want to do and to
what range because if you put an X into a cell everytime you move the cursor
with the SHIFT ALT or CTRL key down you may get some unpleasent supprises.


--
Thanks,
Shane Devenshire


"dwinmac" wrote:

Can someone show me how to code the conditional statement shown in the
comments below i.e. how to put the "x" in the cell only if the SHIFT ( or
ctrl or alt)key is selected.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
RowPos = Target.Row
ColPos = 3
' If Shift Key selected then
' Put an "x" in cell row = RowPos and Column = ColPos
ThisWorkbook.ActiveSheet.Cells(RowPos, ColPos) = "x"
'End If
End Sub



All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com