Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Filter and immediately overwrite same sheet with results

Dear Guru's,

What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:

Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

This gives me a 1004-error: PasteSpecial Method of Range class failed.

What would be the better / correct approach???!!!

TFH, AdP

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Filter and immediately overwrite same sheet with results

Hi

Somthing along the lines of

With ws
.Range("A1").CurrentRegion.Copy
.Range("A1").CurrentRegion.PasteSpecial xlPasteValues
End With

untested with a filtered range

"artisdepartis" wrote:

Dear Guru's,

What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:

Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

This gives me a 1004-error: PasteSpecial Method of Range class failed.

What would be the better / correct approach???!!!

TFH, AdP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Filter and immediately overwrite same sheet with results

Bad advise on my part in my last post - please disregard

will continue testing

"artisdepartis" wrote:

Dear Guru's,

What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:

Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

This gives me a 1004-error: PasteSpecial Method of Range class failed.

What would be the better / correct approach???!!!

TFH, AdP


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Filter and immediately overwrite same sheet with results

On Jun 21, 12:48 pm, steve_doc
wrote:
Bad advise on my part in my last post - please disregard

will continue testing



"artisdepartis" wrote:
Dear Guru's,


What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:


Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


This gives me a 1004-error: PasteSpecial Method of Range class failed.


What would be the better / correct approach???!!!


TFH, AdP- Hide quoted text -


- Show quoted text -


Is this even doable? I can't seem to work around an error message
regarding the size of my copy region.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Filter and immediately overwrite same sheet with results

I dont think that it is possible - but could well be wrong

The only way I managed to get around this was to paste the data to a
different(Temporary) location and copy/paste it back after deleting the
original.

"artisdepartis" wrote:

On Jun 21, 12:48 pm, steve_doc
wrote:
Bad advise on my part in my last post - please disregard

will continue testing



"artisdepartis" wrote:
Dear Guru's,


What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:


Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


This gives me a 1004-error: PasteSpecial Method of Range class failed.


What would be the better / correct approach???!!!


TFH, AdP- Hide quoted text -


- Show quoted text -


Is this even doable? I can't seem to work around an error message
regarding the size of my copy region.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Filter and immediately overwrite same sheet with results

Steve, TY for trying.

I have come to the same conclusion. Although i do not like it one
bit :S
(Not that it is critical, but in my case i need to create this new
location (add a sheet) and refer to the added sheet.

AdP

On Jun 22, 3:41 pm, steve_doc
wrote:
I dont think that it is possible - but could well be wrong

The only way I managed to get around this was to paste the data to a
different(Temporary) location and copy/paste it back after deleting the
original.



"artisdepartis" wrote:
On Jun 21, 12:48 pm, steve_doc
wrote:
Bad advise on my part in my last post - please disregard


will continue testing


"artisdepartis" wrote:
Dear Guru's,


What would be the better / correct approach???!!! See my code below.
learning a lot through trail and error, I seem to be stuck again in
the latter: I have a macro in which I filter data, after which I want
to CopyPaste the data.value to the same sheet, overwriting what was
there. I have:


Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Worksheets(sFileNameSource01 & lRecDate).AutoFilterMode = False
Cells.Clear
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


This gives me a 1004-error: PasteSpecial Method of Range class failed.


What would be the better / correct approach???!!!


TFH, AdP- Hide quoted text -


- Show quoted text -


Is this even doable? I can't seem to work around an error message
regarding the size of my copy region.- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
filter results to userform-sheet [email protected] Excel Programming 2 March 7th 07 03:07 PM
Save As - Can I use VBA? to stop XL Sheet overwrite Smudge Excel Discussion (Misc queries) 2 February 8th 07 01:12 AM
Why won't advanced filter return filter results? jaws4518 Excel Worksheet Functions 5 September 12th 06 06:11 PM
How do I link filter results into another sheet? aneczka Excel Worksheet Functions 0 July 7th 06 03:30 PM
Overwrite Master sheet when using merge macro Mark Jackson Excel Programming 3 June 8th 05 09:33 AM


All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"