Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default How to extract data from table in other worksheet

Hi,

I have one table with autofilter, and all I need is a button to copy the
first line of autofilter result in other worksheet, to be able to print data
I wish out.

problem is if i make macro with record, it will copy only the line I
selected, and autofilter keeps the same line numbers, so it will allways
copy the same I selected, and not the one I filtered.

pls....help.

with thanks


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to extract data from table in other worksheet

One way:

Option Explicit
Sub testme()
Dim RngToCopy As Range
Dim DestCell As Range

With Worksheets("sheet1")
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
MsgBox "only the headers are visible"
Exit Sub
End If
'resize to ignore the header
'and come down one row (with the .offset())
Set RngToCopy = .Resize(.Rows.Count - 1).Offset(1, 0) _

..Cells.SpecialCells(xlCellTypeVisible).Rows(1)
End With
End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

RngToCopy.Copy _
Destination:=DestCell

End Sub

Crazy wrote:

Hi,

I have one table with autofilter, and all I need is a button to copy the
first line of autofilter result in other worksheet, to be able to print data
I wish out.

problem is if i make macro with record, it will copy only the line I
selected, and autofilter keeps the same line numbers, so it will allways
copy the same I selected, and not the one I filtered.

pls....help.

with thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to extract data from table in other worksheet

Watch out for wrapping text...

The code didn't change, but the formatting did.

Option Explicit
Sub testme()
Dim RngToCopy As Range
Dim DestCell As Range

With Worksheets("sheet1")
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1 Then
MsgBox "only the headers are visible"
Exit Sub
End If
'resize to avoid the header
'and come down one row
Set RngToCopy = .Resize(.Rows.Count - 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible).Rows(1)
End With
End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

RngToCopy.Copy _
Destination:=DestCell

End Sub


Dave Peterson wrote:
<<snipped
Crazy wrote:

Hi,

I have one table with autofilter, and all I need is a button to copy the
first line of autofilter result in other worksheet, to be able to print data
I wish out.

problem is if i make macro with record, it will copy only the line I
selected, and autofilter keeps the same line numbers, so it will allways
copy the same I selected, and not the one I filtered.

pls....help.

with thanks


--

Dave Peterson


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default How to extract data from table in other worksheet

Hi Dave,

What to say than: THANKS, it is great...



"Dave Peterson" wrote in message
...
Watch out for wrapping text...

The code didn't change, but the formatting did.

Option Explicit
Sub testme()
Dim RngToCopy As Range
Dim DestCell As Range

With Worksheets("sheet1")
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible). Count = 1
Then
MsgBox "only the headers are visible"
Exit Sub
End If
'resize to avoid the header
'and come down one row
Set RngToCopy = .Resize(.Rows.Count - 1).Offset(1, 0) _

.Cells.SpecialCells(xlCellTypeVisible).Rows(1)
End With
End With

With Worksheets("sheet2")
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

RngToCopy.Copy _
Destination:=DestCell

End Sub


Dave Peterson wrote:
<<snipped
Crazy wrote:

Hi,

I have one table with autofilter, and all I need is a button to copy
the
first line of autofilter result in other worksheet, to be able to print
data
I wish out.

problem is if i make macro with record, it will copy only the line I
selected, and autofilter keeps the same line numbers, so it will
allways
copy the same I selected, and not the one I filtered.

pls....help.

with thanks


--

Dave Peterson


--

Dave Peterson



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
Extract Client Refs from pivot table into another worksheet Sarah (OGI) Excel Worksheet Functions 0 April 4th 07 01:02 PM
Extract data from a table shnim1 Excel Worksheet Functions 6 February 5th 07 01:18 AM
Extract Data From A Table zephyr Excel Discussion (Misc queries) 0 November 16th 06 04:43 PM
HOW TO EXTRACT (or lookup) DATA FROM A PIVOT TABLE SSJ New Users to Excel 3 November 9th 06 09:46 PM
Formula to Extract Data from a Table Macshots Excel Worksheet Functions 2 November 5th 04 06:35 AM


All times are GMT +1. The time now is 09:22 PM.

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

About Us

"It's about Microsoft Excel"