PC Review


Reply
Thread Tools Rate Thread

Assigning a hotkey to run only from a given range

 
 
Andyjim
Guest
Posts: n/a
 
      25th Dec 2007
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 With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      25th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:EB4DD564-6A94-4040-82B6-(E-Mail Removed)...
> 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 With Quote
 
Andyjim
Guest
Posts: n/a
 
      26th Dec 2007
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" <(E-Mail Removed)> wrote in message
> news:EB4DD564-6A94-4040-82B6-(E-Mail Removed)...
> > 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 With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      27th Dec 2007
Thanks for the feedback. Otto
"Andyjim" <(E-Mail Removed)> wrote in message
news:8C3E9EAF-DDF2-48ED-8CFF-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:EB4DD564-6A94-4040-82B6-(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning Value to a Range of Numbers jrs Microsoft Access Getting Started 1 7th Aug 2009 04:29 AM
Assigning AutoFiltered Range to Range Object Simon Microsoft Excel Programming 5 11th Mar 2009 01:04 AM
Assigning range to variant vezerid Microsoft Excel Programming 2 12th Mar 2007 04:46 PM
Assigning an IP range for ICS =?Utf-8?B?SGF3a2V5ZQ==?= Windows XP Networking 2 16th Dec 2004 06:21 PM
Assigning a Range to Alex A Microsoft Excel Programming 2 30th Jan 2004 12:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.