![]() |
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial
2003/2007
This code works: Dim SrchAcctRng as Range SrchAcctRng.Select SrchAcctRng.Copy Selection.PasteSpecial xlPasteValues Next code fails in range class Dim SrchAcctRng as Range SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues Note that SrchAcctRng is a filtered range as a result of: Set SrchAcctRng = wks.Range(Cells(PrintRow + 1, PrintCol).Address, _ Cells(wks.Cells(Rows.Count, 1).End(xlUp).Row - 1, PrintCol)).SpecialCells(xlCellTypeVisible) I do not usderstand why I need to use Selection.PasteSpecial xlPasteValues? TIA EagleOne |
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial
What happens if you add:
SrchAcctRng.Select to the second example? Mark Lincoln On Jun 25, 11:15 am, wrote: 2003/2007 This code works: Dim SrchAcctRng as Range SrchAcctRng.Select SrchAcctRng.Copy Selection.PasteSpecial xlPasteValues Next code fails in range class Dim SrchAcctRng as Range SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues Note that SrchAcctRng is a filtered range as a result of: Set SrchAcctRng = wks.Range(Cells(PrintRow + 1, PrintCol).Address, _ Cells(wks.Cells(Rows.Count, 1).End(xlUp).Row - 1, PrintCol)).SpecialCells(xlCellTypeVisible) I do not usderstand why I need to use Selection.PasteSpecial xlPasteValues? TIA EagleOne |
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial
this works for me:
Sub test() Dim ws As Worksheet Dim SrchAcctRng As Range Set ws = Worksheets("sheet1") Set SrchAcctRng = ws.Range("A1:C2") SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues End Sub -- Gary wrote in message ... 2003/2007 This code works: Dim SrchAcctRng as Range SrchAcctRng.Select SrchAcctRng.Copy Selection.PasteSpecial xlPasteValues Next code fails in range class Dim SrchAcctRng as Range SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues Note that SrchAcctRng is a filtered range as a result of: Set SrchAcctRng = wks.Range(Cells(PrintRow + 1, PrintCol).Address, _ Cells(wks.Cells(Rows.Count, 1).End(xlUp).Row - 1, PrintCol)).SpecialCells(xlCellTypeVisible) I do not usderstand why I need to use Selection.PasteSpecial xlPasteValues? TIA EagleOne |
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial
sorry, didn't see the filtered range
-- Gary "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... this works for me: Sub test() Dim ws As Worksheet Dim SrchAcctRng As Range Set ws = Worksheets("sheet1") Set SrchAcctRng = ws.Range("A1:C2") SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues End Sub -- Gary wrote in message ... 2003/2007 This code works: Dim SrchAcctRng as Range SrchAcctRng.Select SrchAcctRng.Copy Selection.PasteSpecial xlPasteValues Next code fails in range class Dim SrchAcctRng as Range SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues Note that SrchAcctRng is a filtered range as a result of: Set SrchAcctRng = wks.Range(Cells(PrintRow + 1, PrintCol).Address, _ Cells(wks.Cells(Rows.Count, 1).End(xlUp).Row - 1, PrintCol)).SpecialCells(xlCellTypeVisible) I do not usderstand why I need to use Selection.PasteSpecial xlPasteValues? TIA EagleOne |
Why need to use Selection.PasteSpecial vs myRange.PasteSpecial
Thanks for the thoughts.
Here is what I found: Using 2007, I had not enabled macros (prompt at open) for the WB in which I was "processing" with VBA. When I would get a "macros not enabled" notice, I would reselect Personal.xls in the VBE Explorer and continue editing as if nothing was wrong. By not enabling macros in the object w/b, "some" - but not all - of the VBA code would process. In short, If I enabled macros the object w/b in 2007, all VBA works fine. If not, only some VBA worked. Thanks EagleOne wrote: 2003/2007 This code works: Dim SrchAcctRng as Range SrchAcctRng.Select SrchAcctRng.Copy Selection.PasteSpecial xlPasteValues Next code fails in range class Dim SrchAcctRng as Range SrchAcctRng.Copy SrchAcctRng.PasteSpecial xlPasteValues Note that SrchAcctRng is a filtered range as a result of: Set SrchAcctRng = wks.Range(Cells(PrintRow + 1, PrintCol).Address, _ Cells(wks.Cells(Rows.Count, 1).End(xlUp).Row - 1, PrintCol)).SpecialCells(xlCellTypeVisible) I do not usderstand why I need to use Selection.PasteSpecial xlPasteValues? TIA EagleOne |
All times are GMT +1. The time now is 02:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com