View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default transfering data from a one workbook to another workbook

It is very easy

If you want to test the first code example

Sub copy_1()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'fill in the Source Sheet and range
Set SourceRange = Sheets("Sheet1").Range("A1:K1")

'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("Sheet2")
Lr = LastRow(DestSheet)

'With the information from the LastRow function we can
'create a destination cell and copy/paste the source range
Set DestRange = DestSheet.Range("A" & Lr + 1)
SourceRange.Copy DestRange

With Application
.ScreenUpdating = True
.EnableEvents = True
End With

End Sub


You must also copy this function from my page

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Shoemaker" wrote in message
...
I copied straight from your web site, can you send me an example because I
still cant get it to work

Thanks for all your help

"Ron de Bruin" wrote:

Read good

Important: The macro examples use one function or two functions that
you can find in the last section of this page.


Copy the LastRow function also in your module


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Shoemaker" wrote in message
...
It is giving me a compile error saying (sub or function not defined)

Sub Copy_To_Another_Workbook()

Lr = LastRow(DestSh)

"Ron de Bruin" wrote:

See the last example on this page
http://www.rondebruin.nl/copy1.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"David Shoemaker" wrote in message
...
I have a workbook that i enter data into, and i want to take certain data in
that workbook and transfer it to another workbook with a pivot table so i can
use it like a data base so i can search or orders

.


.