Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Macro to Paste Special

Thanks to a previous posting I have had the following created for me for
copying data to a text file from a spreadsheet I've got.

I need one more thing on this - which if Tom could help this would be really
appreciated, however if anyone else is able to help with this amendment I would
be grateful.

Instead of the macro copying the data over as it is (unfortunately the
spreadsheet uses formulas and therefore when this is copied over it doesn't
copy over some of the data properly) - I need it to copy over as a value.

Once again thanks, Regards - Al ( )

Current Macro:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' rng holds range defined by name "data"
Dim rng As Range
' rngName holds the name for the file
Dim rngName As Range
Dim wkbk As Workbook
With ThisWorkbook.Worksheets(1)
If IsEmpty(.Range("B7")) Then Exit Sub
Set rng = .Range(.Range("B7"), _
.Cells(Rows.Count, 1).End(xlDown))
Set rng = rng.Resize(, 8)
End With
Set rngName = rng.Parent.Range("E2")
Set wkbk = Workbooks.Add
rng.Copy wkbk.Worksheets(1).Range("A1")
' if file exists, overwrite without prompt
Application.DisplayAlerts = False
wkbk.SaveAs FileName:=ThisWorkbook.Path _
& "\" & rngName.Value & ".txt", FileFormat:=xlText
Application.DisplayAlerts = True
wkbk.Close SaveChanges:=False
End Sub

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
Cut & Paste Need Special Macro Miss Kitty[_2_] Excel Discussion (Misc queries) 6 August 25th 08 09:12 PM
PASTE SPECIAL w/ Macro Jase Excel Discussion (Misc queries) 7 February 26th 08 06:06 PM
Paste Special Macro - can't undo Ben New Users to Excel 2 May 10th 07 03:44 AM
Copy Paste Special Macro Bud Hughes Excel Discussion (Misc queries) 2 August 31st 05 02:00 AM
Paste Special in a macro CMAC Excel Worksheet Functions 2 December 6th 04 10:19 PM


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