PC Review


Reply
Thread Tools Rate Thread

Copy Paste Macro not Pasting Values when Blank

 
 
Corey
Guest
Posts: n/a
 
      15th Sep 2008
I recorded a Macro to copy values(only) from 1 sheet to another.
It all works great, except for one range of cells(one with Arrow).

Why ? And how do i fix it?
The rest is Ok.

Code Recorded:
Sub ReplaceOriginalValues()
Sheets("OriginalValues").Visible = True
Range("B9:B48").Select
Selection.Copy
Sheets("CostingSheet").Select
Range("B9:B48").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False ,<=== Not Pasting Correctly
Sheets("OriginalValues").Select
Range("AG13:AG23").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AG13:AG23").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Range("AJ9:AK48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AJ9:AK48").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Range("AG26:AG28").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AG26:AG28").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Range("AG31").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AG31").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Range("AG34:AG48").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AG34:AG48").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Range("AL42").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CostingSheet").Select
Range("AL42").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Sheets("OriginalValues").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False
Sheets("CostingSheet").Select
Range("B3").Select
End Sub


--
Corey ....
The Silliest Question is generally
the one i forgot to ask.


 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      15th Sep 2008
Untested but try selecting the worksheet after making it visible. It might
not be the selected worksheet.

Sheets("OriginalValues").Visible = True
Sheets("OriginalValues").Select

--
Regards,

OssieMac


"Corey" wrote:

> I recorded a Macro to copy values(only) from 1 sheet to another.
> It all works great, except for one range of cells(one with Arrow).
>
> Why ? And how do i fix it?
> The rest is Ok.
>
> Code Recorded:
> Sub ReplaceOriginalValues()
> Sheets("OriginalValues").Visible = True
> Range("B9:B48").Select
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("B9:B48").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False ,<=== Not Pasting Correctly
> Sheets("OriginalValues").Select
> Range("AG13:AG23").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AG13:AG23").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Range("AJ9:AK48").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AJ9:AK48").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Range("AG26:AG28").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AG26:AG28").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Range("AG31").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AG31").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Range("AG34:AG48").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AG34:AG48").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Range("AL42").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("CostingSheet").Select
> Range("AL42").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks:=False, Transpose:=False
> Sheets("OriginalValues").Select
> Application.CutCopyMode = False
> ActiveWindow.SelectedSheets.Visible = False
> Sheets("CostingSheet").Select
> Range("B3").Select
> End Sub
>
>
> --
> Corey ....
> The Silliest Question is generally
> the one i forgot to ask.
>
>
>

 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      16th Sep 2008
Thanks for the reply.

I change the PasteSpecisl to simply Paste and it seem to work now.

"OssieMac" <(E-Mail Removed)> wrote in message
news35665B8-80C8-4213-BB3C-(E-Mail Removed)...
> Untested but try selecting the worksheet after making it visible. It might
> not be the selected worksheet.
>
> Sheets("OriginalValues").Visible = True
> Sheets("OriginalValues").Select
>
> --
> Regards,
>
> OssieMac
>
>
> "Corey" wrote:
>
>> I recorded a Macro to copy values(only) from 1 sheet to another.
>> It all works great, except for one range of cells(one with Arrow).
>>
>> Why ? And how do i fix it?
>> The rest is Ok.
>>
>> Code Recorded:
>> Sub ReplaceOriginalValues()
>> Sheets("OriginalValues").Visible = True
>> Range("B9:B48").Select
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("B9:B48").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False ,<=== Not Pasting Correctly
>> Sheets("OriginalValues").Select
>> Range("AG13:AG23").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AG13:AG23").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Range("AJ9:AK48").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AJ9:AK48").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Range("AG26:AG28").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AG26:AG28").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Range("AG31").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AG31").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Range("AG34:AG48").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AG34:AG48").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Range("AL42").Select
>> Application.CutCopyMode = False
>> Selection.Copy
>> Sheets("CostingSheet").Select
>> Range("AL42").Select
>> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
>> SkipBlanks:=False, Transpose:=False
>> Sheets("OriginalValues").Select
>> Application.CutCopyMode = False
>> ActiveWindow.SelectedSheets.Visible = False
>> Sheets("CostingSheet").Select
>> Range("B3").Select
>> End Sub
>>
>>
>> --
>> Corey ....
>> The Silliest Question is generally
>> the one i forgot to ask.
>>
>>
>>



 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      16th Sep 2008
Hi Corey,

The way you have your code written, the range to copy will be whatever is
the active sheet and if you need to make the sheet visible first then it will
not be the active sheet and therefore you need to select it before selecting
the range to copy.

I have now tested this and although the sheet becomes the active sheet when
unhidden in the interactive mode, it does not record this in the macro and
you need to edit the macro and insert the line of code.

If you believe that it is working now then that is probably because the
sheet is not hidden and is the active sheet when you start the code but if
you hide the sheet again you will find that your code does not work.

--
Regards,

OssieMac


"Corey" wrote:

> Thanks for the reply.
>
> I change the PasteSpecisl to simply Paste and it seem to work now.
>
> "OssieMac" <(E-Mail Removed)> wrote in message
> news35665B8-80C8-4213-BB3C-(E-Mail Removed)...
> > Untested but try selecting the worksheet after making it visible. It might
> > not be the selected worksheet.
> >
> > Sheets("OriginalValues").Visible = True
> > Sheets("OriginalValues").Select
> >
> > --
> > Regards,
> >
> > OssieMac
> >
> >
> > "Corey" wrote:
> >
> >> I recorded a Macro to copy values(only) from 1 sheet to another.
> >> It all works great, except for one range of cells(one with Arrow).
> >>
> >> Why ? And how do i fix it?
> >> The rest is Ok.
> >>
> >> Code Recorded:
> >> Sub ReplaceOriginalValues()
> >> Sheets("OriginalValues").Visible = True
> >> Range("B9:B48").Select
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("B9:B48").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False ,<=== Not Pasting Correctly
> >> Sheets("OriginalValues").Select
> >> Range("AG13:AG23").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AG13:AG23").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Range("AJ9:AK48").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AJ9:AK48").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Range("AG26:AG28").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AG26:AG28").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Range("AG31").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AG31").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Range("AG34:AG48").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AG34:AG48").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Range("AL42").Select
> >> Application.CutCopyMode = False
> >> Selection.Copy
> >> Sheets("CostingSheet").Select
> >> Range("AL42").Select
> >> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> >> SkipBlanks:=False, Transpose:=False
> >> Sheets("OriginalValues").Select
> >> Application.CutCopyMode = False
> >> ActiveWindow.SelectedSheets.Visible = False
> >> Sheets("CostingSheet").Select
> >> Range("B3").Select
> >> End Sub
> >>
> >>
> >> --
> >> Corey ....
> >> The Silliest Question is generally
> >> the one i forgot to ask.
> >>
> >>
> >>

>
>
>

 
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
copy paste values macro Wanna Learn Microsoft Excel Misc 5 21st Jul 2009 04:44 PM
Macro to copy and paste values (columns)I have a macro file built C02C04 Microsoft Excel Programming 2 2nd May 2008 01:51 PM
Macro for copy and paste values excelnerd Microsoft Excel Misc 3 8th Mar 2008 06:51 PM
Copy and Paste Values - Using VB or Macro Brig Siton Microsoft Excel Discussion 0 17th Aug 2006 05:16 PM
Macro copy and paste = blank worksheet efface Microsoft Excel Misc 1 27th Apr 2006 09:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 AM.