Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Export specific cell values to an external workbook

Please can someone help. I am looking to export only values from one
worksheet to an external workbook. The data to be exported is in a
table format and are formulas. I need to export only those formulas
that return values (the data has been sorted so that it is easier to
export a range as blanks are at the bottom of the data table. Is
there a code that i can use that will do this for me? I will need to
run this macro several times to create a number of new sheets in a
workbook as the data in the original is updated and the number of
cells that contain values changes.

i have tried the the code below but this coipes all (including formats
and formulas):

Sub Test()
Dim bk As Workbook
Dim bSave As Boolean
Dim lRow As Long

On Error Resume Next
Set bk = Workbooks("File.xls")
On Error GoTo 0
If bk Is Nothing Then
bSave = True
Set bk = Workbooks.Open("Path\File.xls")
End If

lRow = bk.Worksheets("Sheet").Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ThisWorkbook.Sheets("Sheet").Range("B1:H170").Copy _
Destination:=bk.Worksheets("Sheet").Cells(lRow, 1)

If bSave Then bk.Close Savechanges:=True

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Export specific cell values to an external workbook

Razorboy
you were close

Change this:
ThisWorkbook.Sheets("Sheet").Range("B1:H170").Copy _
Destination:=bk.Worksheets("Sheet").Cells(lRow, 1)

(one logical line with a _ continuation)
to this

ThisWorkbook.Sheets("Sheet").Range("B1:H170").Copy
bk.Worksheets("Sheet").Cells(lRow, 1).pastespecial xlpastevalues

(two lines)

Cheers
Simon
Excel development website: www.codematic.net


Razorboy wrote:
Please can someone help. I am looking to export only values from one
worksheet to an external workbook. The data to be exported is in a
table format and are formulas. I need to export only those formulas
that return values (the data has been sorted so that it is easier to
export a range as blanks are at the bottom of the data table. Is
there a code that i can use that will do this for me? I will need to
run this macro several times to create a number of new sheets in a
workbook as the data in the original is updated and the number of
cells that contain values changes.

i have tried the the code below but this coipes all (including formats
and formulas):

Sub Test()
Dim bk As Workbook
Dim bSave As Boolean
Dim lRow As Long

On Error Resume Next
Set bk = Workbooks("File.xls")
On Error GoTo 0
If bk Is Nothing Then
bSave = True
Set bk = Workbooks.Open("Path\File.xls")
End If

lRow = bk.Worksheets("Sheet").Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
ThisWorkbook.Sheets("Sheet").Range("B1:H170").Copy _
Destination:=bk.Worksheets("Sheet").Cells(lRow, 1)

If bSave Then bk.Close Savechanges:=True

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
Copy a specific range of cell values into an external workbook Razorboy Excel Programming 0 October 27th 08 03:57 PM
export a workbook to specific loc on other computer via internet pswanie Excel Programming 0 June 17th 07 01:48 PM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
Export Specific Sheet in Listbox to New Workbook Carlee Excel Programming 1 April 13th 07 07:56 PM
External hyperlink to a specific page in a workbook Nimbus55 Excel Worksheet Functions 2 July 31st 06 01:07 PM


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