PC Review


Reply
Thread Tools Rate Thread

code is not selecting correct range

 
 
=?Utf-8?B?U3RldmVD?=
Guest
Posts: n/a
 
      21st Sep 2007
I have a strange problem -- the macro is not selecting, copying or pasting to
the correct ranges. When I do a F8 step by step debug review, it seems as if
it actually skips the Range(...).Select code.

The new select and paste ranges that are not be selected properly were
edited from previously coded ranges -- the macro is still selecting the old
ranges but the ranges are not coded in this macro! how do I fix this?
thanks.

Steve

Sub Set_Price()
'
' Set_Buyback_Price Macro

Sheets("A4_Targets").Select
Range("f13:f28").Select
Selection.Copy
Sheets("A1_Scenario Input").Select
Range("cq331").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Sheets("A4_Targets").Select
Range("f36:f51").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("A1_Scenario Input").Select
Range("cr301").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
 
Reply With Quote
 
 
 
 
Bob Umlas
Guest
Posts: n/a
 
      21st Sep 2007
Is this stored in a regular module (as opposed to a sheet module)?
And you can streamline the code by doing no selecting:
For example, change this:
Sheets("A4_Targets").Select
Range("f13:f28").Select
Selection.Copy
Sheets("A1_Scenario Input").Select
Range("cq331").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

to this:
Sheets("A4_Targets").Range("f13:f28").Copy
Sheets("A1_Scenario Input").Range("cq331").PasteSpecial
Paste:=xlPasteValues

Bob Umlas
Excel MVP

"SteveC" <(E-Mail Removed)> wrote in message
news:2F9D78E8-46C8-4E66-9EE2-(E-Mail Removed)...
>I have a strange problem -- the macro is not selecting, copying or pasting
>to
> the correct ranges. When I do a F8 step by step debug review, it seems as
> if
> it actually skips the Range(...).Select code.
>
> The new select and paste ranges that are not be selected properly were
> edited from previously coded ranges -- the macro is still selecting the
> old
> ranges but the ranges are not coded in this macro! how do I fix this?
> thanks.
>
> Steve
>
> Sub Set_Price()
> '
> ' Set_Buyback_Price Macro
>
> Sheets("A4_Targets").Select
> Range("f13:f28").Select
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cq331").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
>
> Sheets("A4_Targets").Select
> Range("f36:f51").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cr301").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False



 
Reply With Quote
 
=?Utf-8?B?QXJuaWU=?=
Guest
Posts: n/a
 
      21st Sep 2007
Since this code was edited from an existing macro, I wonder if the original
macro still exists? If so, is it possible that the old macro is being called
instead of the edited one (i.e. old macro still assigned to a button or old
macro name being selected from the list)?

Just a thought.
--
n00b lookn for a handout


"SteveC" wrote:

> I have a strange problem -- the macro is not selecting, copying or pasting to
> the correct ranges. When I do a F8 step by step debug review, it seems as if
> it actually skips the Range(...).Select code.
>
> The new select and paste ranges that are not be selected properly were
> edited from previously coded ranges -- the macro is still selecting the old
> ranges but the ranges are not coded in this macro! how do I fix this?
> thanks.
>
> Steve
>
> Sub Set_Price()
> '
> ' Set_Buyback_Price Macro
>
> Sheets("A4_Targets").Select
> Range("f13:f28").Select
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cq331").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
>
> Sheets("A4_Targets").Select
> Range("f36:f51").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cr301").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False

 
Reply With Quote
 
=?Utf-8?B?a2Fzc2ll?=
Guest
Posts: n/a
 
      21st Sep 2007
Hi

Try the following:
Sheets("A1_Scenario Input").Activate
Sheets("A4_Target").Range("F13:F28").Copy
Range("C1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
Skipblanks:=False, Transpose:=False
Sheets("A4_Target").Range("F36:F51").Copy
Range("d1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
Skipblanks:=False, Transpose:=False

It is not necessary to select or even activate a sheet to copy from it.

--
Hth

Kassie Kasselman
Change xxx to hotmail


"SteveC" wrote:

> I have a strange problem -- the macro is not selecting, copying or pasting to
> the correct ranges. When I do a F8 step by step debug review, it seems as if
> it actually skips the Range(...).Select code.
>
> The new select and paste ranges that are not be selected properly were
> edited from previously coded ranges -- the macro is still selecting the old
> ranges but the ranges are not coded in this macro! how do I fix this?
> thanks.
>
> Steve
>
> Sub Set_Price()
> '
> ' Set_Buyback_Price Macro
>
> Sheets("A4_Targets").Select
> Range("f13:f28").Select
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cq331").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
>
> Sheets("A4_Targets").Select
> Range("f36:f51").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("A1_Scenario Input").Select
> Range("cr301").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False

 
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
macro code selecting moving range KDG Microsoft Excel Programming 3 30th Jul 2009 02:29 PM
Selecting the correct range =?Utf-8?B?VHJldmVyIEI=?= Microsoft Excel Programming 8 9th Mar 2007 11:03 AM
Selecting the correct number from a range of cells pajones via OfficeKB.com Microsoft Excel Worksheet Functions 8 18th Sep 2006 04:04 PM
Selecting the correct number from a range of cells pajones via OfficeKB.com Microsoft Excel Worksheet Functions 0 18th Sep 2006 02:55 PM
Selecting a range in code =?Utf-8?B?SkNhbnlvbmVlcg==?= Microsoft Excel Programming 4 20th Dec 2004 11:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 AM.