Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

code is not selecting correct range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveC - 21 Sep 2007 17:34 GMT
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
Bob Umlas - 21 Sep 2007 20:35 GMT
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

>I have a strange problem -- the macro is not selecting, copying or pasting
>to
[quoted text clipped - 32 lines]
> SkipBlanks _
>        :=False, Transpose:=False
Arnie - 21 Sep 2007 20:36 GMT
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.
Signature

n00b lookn for a handout  :)

> 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
[quoted text clipped - 29 lines]
> SkipBlanks _
>         :=False, Transpose:=False
kassie - 21 Sep 2007 20:42 GMT
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.

Signature

Hth

Kassie Kasselman
Change xxx to hotmail

> 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
[quoted text clipped - 29 lines]
> SkipBlanks _
>         :=False, Transpose:=False
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.