Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Extract Data from Dataset

I'm looking to extract data that meets a certain criteria but not sure how to do it via a macro. What I'm after:-

Workbook1= Dataset
Workbook2 = Where it will be extracted to (copied not cut)
I will copy rows 1-12 as headers first
Based on a value I input in a Dialogue box, this is the data that will be extracted to new Workbook2
The value input above will reside in Column A (starting at Row 13) in Workbook1
Once matched I will copy all the Row
The match/copy process will continue until it hits the first blank cell in Column A, signifying the end of the Dataset
Then Copying the column widths in Workbook1 to match Workbook2

I hope above makes sense
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Extract Data from Dataset

check this out !! Name your sheet as Dataset which contains data and name another sheet as output sheet.


Sub CopyRows()

Dim ws As Worksheet
Dim wsout As Worksheet
Dim lr As Long

Set ws = ActiveWorkbook.Sheets("dataset") 'dataset sheet
Set wsout = ActiveWorkbook.Sheets("output") 'output sheet

'Getting values in this variable
tempval = InputBox("Enter the value")

'Copying first 12 rows
ws.Rows("1:12").Copy Destination:=wsout.Range("A1")

'find last row from your Dataset sheet
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row

'Filter all rows matching criteria You can adjust your columns by changing F to your defined column
ws.Range("A12:F" & lr).AutoFilter field:=1, Criteria1:=tempval
ws.Range("A12:F" & lr).SpecialCells(xlCellTypeVisible).Copy Destination:=wsout.Range("A12")

'turn off filter mode
ActiveSheet.AutoFilterMode = False

End Sub

Regards,
Mandeep baluja
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Extract Data from Dataset

Hey, that works pretty good, thanks, some things I'd like to change

-Instead of specifying the originating sheet name, can the code just work from the 'active sheet'?
-Instead of specifying the destination sheet in the same workbook, can it auto create a new workbook
-Can you format the 'new workbook' sheet in the same format as 'originating workbook' sheet

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
how to extract a dataset to the active cell? NA_AB Excel Programming 2 December 29th 08 07:19 AM
Charting only partial data from a large dataset forest8 Charts and Charting in Excel 2 February 23rd 08 08:56 PM
Sorting dataset automatically after entering data in a row [or cel MatthewS Excel Discussion (Misc queries) 3 August 7th 06 09:47 PM
assign dataset to matching dataset Michael Dirksen Excel Programming 0 June 16th 06 04:34 PM
Converting A Quarterly Dataset to Weekly Dataset Dan Thompson Excel Programming 5 November 25th 05 09:27 PM


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