Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Macro to copy a range

I have asked in other NG. Got some very good answers from very helpful
people (The trouble was that these people assumed that I know a great deal
about EXcel...I do not)that left me a little confused. Here is my
predicament
I have a sheet called db1
The sheet contains data in Col A, B ,C, D,E,F,G,H,I,J
I have applied a filter to this sheet. Col A is set to show only NON BLANK
lines

I want to copy the data currently displayed(Ie NON blank lines) to and other
sheet
The columns are always the same ones but the number of rows varies all the
time.
So I need a macro that will copy from ALL and only the visible data.
(ie copy the data in the above named columns down to the last row showing .
Can/will some one give me the code required to do this.
Thanks and Have a very happy 2004
--
Norton Professional 2004 says this email is clean...believe it


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Macro to copy a range

One way:

Public Sub CopyVisible()
Sheets("db1").Range("A1").CurrentRegion.SpecialCel ls( _
xlCellTypeVisible).Copy Destination:=Sheets(2).Range("A1")
End Sub

In article
.rogers.com,
"PCOR" wrote:

I have asked in other NG. Got some very good answers from very helpful
people (The trouble was that these people assumed that I know a great deal
about EXcel...I do not)that left me a little confused. Here is my
predicament
I have a sheet called db1
The sheet contains data in Col A, B ,C, D,E,F,G,H,I,J
I have applied a filter to this sheet. Col A is set to show only NON BLANK
lines

I want to copy the data currently displayed(Ie NON blank lines) to and other
sheet
The columns are always the same ones but the number of rows varies all the
time.
So I need a macro that will copy from ALL and only the visible data.
(ie copy the data in the above named columns down to the last row showing .
Can/will some one give me the code required to do this.
Thanks and Have a very happy 2004

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Macro to copy a range

Thank you for the code.
It did the trick and did copy the data to the second sheet....BUT
I also received an error message
"Run time error 1004"
"Copy method of range class failed"
I wonder why the error

"J.E. McGimpsey" wrote in message
...
One way:

Public Sub CopyVisible()
Sheets("db1").Range("A1").CurrentRegion.SpecialCel ls( _
xlCellTypeVisible).Copy Destination:=Sheets(2).Range("A1")
End Sub

In article
.rogers.com,
"PCOR" wrote:

I have asked in other NG. Got some very good answers from very helpful
people (The trouble was that these people assumed that I know a great

deal
about EXcel...I do not)that left me a little confused. Here is my
predicament
I have a sheet called db1
The sheet contains data in Col A, B ,C, D,E,F,G,H,I,J
I have applied a filter to this sheet. Col A is set to show only NON

BLANK
lines

I want to copy the data currently displayed(Ie NON blank lines) to and

other
sheet
The columns are always the same ones but the number of rows varies all

the
time.
So I need a macro that will copy from ALL and only the visible data.
(ie copy the data in the above named columns down to the last row

showing .
Can/will some one give me the code required to do this.
Thanks and Have a very happy 2004



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro to copy a range

hope the following helps, if someone more knoledgable than me is checking my
code, what variant type should i give to "rng"


Sub CopyNonBlanks()
Dim i As Integer, rng As Variant
Application.ScreenUpdating = False
sheets("db1").select
i = 0
For Each rng In Range(Range(("A1")), Range("A1").End(xlDown))
If rng < "" Then
Range(rng, rng.Offset(0, 9)).Copy
Sheets("Sheet2").Range("A1").Offset(i, 0).PasteSpecial
i = i + 1
End If
Next rng
CutCopyMode = False
End Sub


PCOR wrote in message
able.rogers.com...
I have asked in other NG. Got some very good answers from very helpful
people (The trouble was that these people assumed that I know a great deal
about EXcel...I do not)that left me a little confused. Here is my
predicament
I have a sheet called db1
The sheet contains data in Col A, B ,C, D,E,F,G,H,I,J
I have applied a filter to this sheet. Col A is set to show only NON BLANK
lines

I want to copy the data currently displayed(Ie NON blank lines) to and

other
sheet
The columns are always the same ones but the number of rows varies all

the
time.
So I need a macro that will copy from ALL and only the visible data.
(ie copy the data in the above named columns down to the last row showing

..
Can/will some one give me the code required to do this.
Thanks and Have a very happy 2004
--
Norton Professional 2004 says this email is clean...believe it




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Macro to copy a range

In article ,
"Stuart" wrote:

what variant type should i give to "rng"


Range


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
Macro to find value and then copy associated range hnyb1 Excel Discussion (Misc queries) 1 December 31st 09 04:09 PM
Macro copy from range puiuluipui Excel Discussion (Misc queries) 3 October 19th 09 05:03 PM
macro to copy range Frank Situmorang[_2_] Excel Worksheet Functions 7 June 3rd 08 09:54 AM
MACRO TO COPY TO A RANGE asuncionw Excel Discussion (Misc queries) 3 February 9th 06 04:39 PM
Macro to copy a range jamesa Excel Programming 2 September 19th 03 12:33 PM


All times are GMT +1. The time now is 10:43 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"