Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copying, Pasting and Saving as (delimted.txt) on seperate sheets

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copying, Pasting and Saving as (delimted.txt) on seperate sheets

This expects headers in D1.

Then it does an advanced filter to show the unique entries
(data|filter|advancedfilter in xl2003 menus).

Then it keeps track of those visible cells and applies data|filter|autofilter to
column D for each one of those unique entries.

It saves the files using each unique value--Hopefully, they won't be invalid
filenames!

And stores them in C:\temp. Make sure the output folder exists before you test
it.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myUniques As Range
Dim VRng As Range
Dim wks As Worksheet
Dim tempWks As Worksheet

Set wks = Worksheets("sheet1")
With wks
'remove any existing autofilter
.AutoFilterMode = False
Set myRng = .Range("D1", .Cells(.Rows.Count, "D").End(xlUp))
With myRng
.AdvancedFilter action:=xlFilterInPlace, unique:=True

Set myUniques = Nothing
On Error Resume Next
'come down one row to avoid the header
Set myUniques = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myUniques Is Nothing Then
MsgBox "Nothing under D1!"
Exit Sub
End If

For Each myCell In myUniques.Cells
.AutoFilter field:=1, Criteria1:=myCell.Value
Set VRng = Nothing
On Error Resume Next
'come down one row, but include 5 columns!
Set VRng = .Resize(.Rows.Count - 1, 5).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "something bad happened with: " & myCell.Value
Exit Sub
End If
Set tempWks = Workbooks.Add(1).Worksheets(1)
VRng.Copy _
Destination:=tempWks.Range("A1")

With tempWks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\" & myCell.Value & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next myCell
End With
.AutoFilterMode = False
End With

End Sub


T-bone wrote:

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copying, Pasting and Saving as (delimted.txt) on seperate shee

Hi Dave,

Do you think it would be ok to send you my spreadhseet - I can't seem to get
the macro to work and I'm unfortunatley not tecnically minded :-(

Thanks

T-bone

"Dave Peterson" wrote:

This expects headers in D1.

Then it does an advanced filter to show the unique entries
(data|filter|advancedfilter in xl2003 menus).

Then it keeps track of those visible cells and applies data|filter|autofilter to
column D for each one of those unique entries.

It saves the files using each unique value--Hopefully, they won't be invalid
filenames!

And stores them in C:\temp. Make sure the output folder exists before you test
it.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myUniques As Range
Dim VRng As Range
Dim wks As Worksheet
Dim tempWks As Worksheet

Set wks = Worksheets("sheet1")
With wks
'remove any existing autofilter
.AutoFilterMode = False
Set myRng = .Range("D1", .Cells(.Rows.Count, "D").End(xlUp))
With myRng
.AdvancedFilter action:=xlFilterInPlace, unique:=True

Set myUniques = Nothing
On Error Resume Next
'come down one row to avoid the header
Set myUniques = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myUniques Is Nothing Then
MsgBox "Nothing under D1!"
Exit Sub
End If

For Each myCell In myUniques.Cells
.AutoFilter field:=1, Criteria1:=myCell.Value
Set VRng = Nothing
On Error Resume Next
'come down one row, but include 5 columns!
Set VRng = .Resize(.Rows.Count - 1, 5).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "something bad happened with: " & myCell.Value
Exit Sub
End If
Set tempWks = Workbooks.Add(1).Worksheets(1)
VRng.Copy _
Destination:=tempWks.Range("A1")

With tempWks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\" & myCell.Value & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next myCell
End With
.AutoFilterMode = False
End With

End Sub


T-bone wrote:

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copying, Pasting and Saving as (delimted.txt) on seperate shee

No thanks.

Describe your problems in plain text and post it in this thread. You'll have
lots of potential helpers.



T-bone wrote:

Hi Dave,

Do you think it would be ok to send you my spreadhseet - I can't seem to get
the macro to work and I'm unfortunatley not tecnically minded :-(

Thanks

T-bone

"Dave Peterson" wrote:

This expects headers in D1.

Then it does an advanced filter to show the unique entries
(data|filter|advancedfilter in xl2003 menus).

Then it keeps track of those visible cells and applies data|filter|autofilter to
column D for each one of those unique entries.

It saves the files using each unique value--Hopefully, they won't be invalid
filenames!

And stores them in C:\temp. Make sure the output folder exists before you test
it.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myUniques As Range
Dim VRng As Range
Dim wks As Worksheet
Dim tempWks As Worksheet

Set wks = Worksheets("sheet1")
With wks
'remove any existing autofilter
.AutoFilterMode = False
Set myRng = .Range("D1", .Cells(.Rows.Count, "D").End(xlUp))
With myRng
.AdvancedFilter action:=xlFilterInPlace, unique:=True

Set myUniques = Nothing
On Error Resume Next
'come down one row to avoid the header
Set myUniques = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myUniques Is Nothing Then
MsgBox "Nothing under D1!"
Exit Sub
End If

For Each myCell In myUniques.Cells
.AutoFilter field:=1, Criteria1:=myCell.Value
Set VRng = Nothing
On Error Resume Next
'come down one row, but include 5 columns!
Set VRng = .Resize(.Rows.Count - 1, 5).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "something bad happened with: " & myCell.Value
Exit Sub
End If
Set tempWks = Workbooks.Add(1).Worksheets(1)
VRng.Copy _
Destination:=tempWks.Range("A1")

With tempWks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\" & myCell.Value & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next myCell
End With
.AutoFilterMode = False
End With

End Sub


T-bone wrote:

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copying, Pasting and Saving as (delimted.txt) on seperate shee

I got it to work! Thanks so much for your time and help! Much appreciated!
;o)

"Dave Peterson" wrote:

No thanks.

Describe your problems in plain text and post it in this thread. You'll have
lots of potential helpers.



T-bone wrote:

Hi Dave,

Do you think it would be ok to send you my spreadhseet - I can't seem to get
the macro to work and I'm unfortunatley not tecnically minded :-(

Thanks

T-bone

"Dave Peterson" wrote:

This expects headers in D1.

Then it does an advanced filter to show the unique entries
(data|filter|advancedfilter in xl2003 menus).

Then it keeps track of those visible cells and applies data|filter|autofilter to
column D for each one of those unique entries.

It saves the files using each unique value--Hopefully, they won't be invalid
filenames!

And stores them in C:\temp. Make sure the output folder exists before you test
it.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myUniques As Range
Dim VRng As Range
Dim wks As Worksheet
Dim tempWks As Worksheet

Set wks = Worksheets("sheet1")
With wks
'remove any existing autofilter
.AutoFilterMode = False
Set myRng = .Range("D1", .Cells(.Rows.Count, "D").End(xlUp))
With myRng
.AdvancedFilter action:=xlFilterInPlace, unique:=True

Set myUniques = Nothing
On Error Resume Next
'come down one row to avoid the header
Set myUniques = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myUniques Is Nothing Then
MsgBox "Nothing under D1!"
Exit Sub
End If

For Each myCell In myUniques.Cells
.AutoFilter field:=1, Criteria1:=myCell.Value
Set VRng = Nothing
On Error Resume Next
'come down one row, but include 5 columns!
Set VRng = .Resize(.Rows.Count - 1, 5).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "something bad happened with: " & myCell.Value
Exit Sub
End If
Set tempWks = Workbooks.Add(1).Worksheets(1)
VRng.Copy _
Destination:=tempWks.Range("A1")

With tempWks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\" & myCell.Value & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next myCell
End With
.AutoFilterMode = False
End With

End Sub


T-bone wrote:

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copying, Pasting and Saving as (delimted.txt) on seperate shee

Glad you got it working!

T-bone wrote:

I got it to work! Thanks so much for your time and help! Much appreciated!
;o)

"Dave Peterson" wrote:

No thanks.

Describe your problems in plain text and post it in this thread. You'll have
lots of potential helpers.



T-bone wrote:

Hi Dave,

Do you think it would be ok to send you my spreadhseet - I can't seem to get
the macro to work and I'm unfortunatley not tecnically minded :-(

Thanks

T-bone

"Dave Peterson" wrote:

This expects headers in D1.

Then it does an advanced filter to show the unique entries
(data|filter|advancedfilter in xl2003 menus).

Then it keeps track of those visible cells and applies data|filter|autofilter to
column D for each one of those unique entries.

It saves the files using each unique value--Hopefully, they won't be invalid
filenames!

And stores them in C:\temp. Make sure the output folder exists before you test
it.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim myUniques As Range
Dim VRng As Range
Dim wks As Worksheet
Dim tempWks As Worksheet

Set wks = Worksheets("sheet1")
With wks
'remove any existing autofilter
.AutoFilterMode = False
Set myRng = .Range("D1", .Cells(.Rows.Count, "D").End(xlUp))
With myRng
.AdvancedFilter action:=xlFilterInPlace, unique:=True

Set myUniques = Nothing
On Error Resume Next
'come down one row to avoid the header
Set myUniques = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myUniques Is Nothing Then
MsgBox "Nothing under D1!"
Exit Sub
End If

For Each myCell In myUniques.Cells
.AutoFilter field:=1, Criteria1:=myCell.Value
Set VRng = Nothing
On Error Resume Next
'come down one row, but include 5 columns!
Set VRng = .Resize(.Rows.Count - 1, 5).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "something bad happened with: " & myCell.Value
Exit Sub
End If
Set tempWks = Workbooks.Add(1).Worksheets(1)
VRng.Copy _
Destination:=tempWks.Range("A1")

With tempWks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\" & myCell.Value & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Close savechanges:=False
End With
Next myCell
End With
.AutoFilterMode = False
End With

End Sub


T-bone wrote:

Hi,

I have a spreadsheet which general information, that I need to cut and paste
into another workbook and save as a delimited txt file.

The current spreadsheet I am working on contains 8 columns. In cell D, I
have a series of numbers that Cells E, F, G and H link to. - Im not really
interested in Columns A-C.

Cell D may contain anything from 1 row to 100+ rows of the same number. I
need to filter on a particular number (if I put the filter application on it
shows me each unique number) and once filtered I need to copy and past the
contents of Cells D, E, F, G and H to another workbook and save this as a
"Text (tab delimited) (*txt)".

To do this manually is a right pain in the rear as the spreadsheet is
approx. 11652 rows, which is ever growing.

I wanted to know if there is a way I can write/create a macro for this
spreadsheet, so we can run it on a weekly basis if any more information gets
added.

Your help would be much appreciated!

Thanks

T-bone!

--

Dave Peterson


--

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
add two cells from seperate work sheets into a cell on seperate wo lar Excel Worksheet Functions 6 April 27th 10 06:54 PM
Copying store numbers and pasting them into a seperate workbook punter Excel Discussion (Misc queries) 2 May 26th 06 11:24 PM
HELP: Copying and pasting to Sheets... aking1987[_16_] Excel Programming 1 November 22nd 04 11:14 AM
HELP: Copying and pasting to Sheets... aking1987[_15_] Excel Programming 0 November 18th 04 10:28 AM
Problem copying range and pasting to multiple sheets Murphy Excel Programming 1 October 9th 03 07:13 PM


All times are GMT +1. The time now is 11:31 AM.

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"