PC Review


Reply
Thread Tools Rate Thread

Copy a specific range of cell values into an external workbook

 
 
Razorboy
Guest
Posts: n/a
 
      27th Oct 2008
Could someone please help with the following...

I have a worksheet containing a table of information and want to
export only the values of a specific range of cells into an external
workbook. The cells in the table all contain formulas, however i only
want to export those that are not blank (""). I need to export the
cell values each time the table is updated - the number of cells to be
copied will alter each time. This last part doesn't need to be
written into the macro, i would like to run it separately each time
the values are updated.

I have tried the following code, but this simply copies the cell
contents (including formats and formulas) into an external workbook.

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

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

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

If bSave Then bk.Close Savechanges:=True

End Sub

Can anyone help?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export specific cell values to an external workbook Razorboy Microsoft Excel Programming 1 28th Oct 2008 02:08 AM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. amorrison2006@googlemail.com Microsoft Excel Programming 1 13th May 2007 01:46 PM
Copy Range to a New WorkBook + Name Sheet a cell Value + Name WorkBook another Celll Value Corey Microsoft Excel Programming 2 2nd Nov 2006 05:01 AM
Linking a range from an external workbook to a single cell philipd Microsoft Excel Misc 3 13th Apr 2004 11:04 PM
Cell range copy to second workbook GerryK Microsoft Excel Worksheet Functions 2 25th Mar 2004 05:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:54 PM.