Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Assigning a hotkey to run only from a given range

We need to ensure that a hot key will only activate from a given range (in
this case any cell in Column B). The code below shows 2 attempts (1 attempt
is commented out). Any help on this would be greatly appreciated!

ActiveCell.Select
If ActiveCell = "controlPrange" Then
'If Selection.Locked = True Then
'Exit Sub
ActiveCell.Offset(rowoffset:=0, columnoffset:=37).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-26).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Copy from Optimum Position Size Formula cell to Optimum Position Size cell
ActiveCell.Offset(rowoffset:=0, columnoffset:=27).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-29).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(rowoffset:=0, columnoffset:=-9).Activate
Else
Exit Sub
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Assigning a hotkey to run only from a given range

Perfect! Thanks so much Otto!

"Otto Moehrbach" wrote:

Not sure what you want. I'll assume that you want your code to run only if
the active cell is in Column B. Something like this might work for you.
HTH Otto
Sub DoIt
If Not Intersect(ActiveCell, Columns("B:B")) Is Nothing Then
'Your code here
End If
End Sub
"Andyjim" wrote in message
...
We need to ensure that a hot key will only activate from a given range (in
this case any cell in Column B). The code below shows 2 attempts (1
attempt
is commented out). Any help on this would be greatly appreciated!

ActiveCell.Select
If ActiveCell = "controlPrange" Then
'If Selection.Locked = True Then
'Exit Sub
ActiveCell.Offset(rowoffset:=0, columnoffset:=37).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-26).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Copy from Optimum Position Size Formula cell to Optimum Position Size
cell
ActiveCell.Offset(rowoffset:=0, columnoffset:=27).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-29).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(rowoffset:=0, columnoffset:=-9).Activate
Else
Exit Sub
End If




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Assigning a hotkey to run only from a given range

Thanks for the feedback. Otto
"Andyjim" wrote in message
...
Perfect! Thanks so much Otto!

"Otto Moehrbach" wrote:

Not sure what you want. I'll assume that you want your code to run only
if
the active cell is in Column B. Something like this might work for you.
HTH Otto
Sub DoIt
If Not Intersect(ActiveCell, Columns("B:B")) Is Nothing Then
'Your code here
End If
End Sub
"Andyjim" wrote in message
...
We need to ensure that a hot key will only activate from a given range
(in
this case any cell in Column B). The code below shows 2 attempts (1
attempt
is commented out). Any help on this would be greatly appreciated!

ActiveCell.Select
If ActiveCell = "controlPrange" Then
'If Selection.Locked = True Then
'Exit Sub
ActiveCell.Offset(rowoffset:=0, columnoffset:=37).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-26).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Copy from Optimum Position Size Formula cell to Optimum Position Size
cell
ActiveCell.Offset(rowoffset:=0, columnoffset:=27).Activate
Selection.Copy
ActiveCell.Offset(rowoffset:=0, columnoffset:=-29).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(rowoffset:=0, columnoffset:=-9).Activate
Else
Exit Sub
End If






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning Variable Range JMay Excel Discussion (Misc queries) 1 July 7th 07 04:52 PM
Assigning range to variant vezerid Excel Programming 2 March 12th 07 04:46 PM
Assigning range to variant vezerid Excel Programming 2 March 12th 07 04:45 PM
Assigning Formula to a Range JMay Excel Programming 5 February 23rd 07 10:12 PM
Assigning a Range to Alex A Excel Programming 2 January 30th 04 12:50 AM


All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"