LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Copy to next empty cell in another workbook

A3 in ActiveSheet is a formula =CONCATENATE(F3&"
"&TEXT($F$7,"DD-MMM-YY")&F2&" ZONE")
The macro (courtesy of Ron de Bruin, amended for workbook,sheet and ranges
only) is required to copy the contents of A3 in the ActiveSheet to the NEXT
EMPTY CELL in Corporate Returns Main.xls!Sheet2 column B. Error: Copying is
always done on Sheet2!B3 and not on successive cells. Could someone tell me
what I am doing wrong.

Sub CorporateReturnsToMain()
'
' CorporateReturnsToMain Macro

'
Dim sourceRange As Range
Dim destrange As Range
Dim destWB As Workbook
Dim Lr As Long

Application.ScreenUpdating = False
If bIsBookOpen("Corporate Returns Main.xls") Then
Set destWB = Workbooks("Corporate Returns Main.xls")
Else
Set destWB = Workbooks.Open("c:\Zone1\Corporate Returns Main.xls")
End If
Lr = LastRow(destWB.Worksheets("Sheet2")) + 1
Set sourceRange = ThisWorkbook.ActiveSheet.Range("A3")
Set destrange = destWB.Worksheets("Sheet2").Range("B" & Lr)
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
Application.ScreenUpdating = True

'
End Sub
======
Function LastRow(sh As Worksheet)


On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("B2"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
=====
Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Thank you
--
Robert
 
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 empty cells from one workbook to another - Code David Choen Excel Programming 1 September 23rd 05 04:11 PM
Copy empty cells from one workbook to another - Code Dave Peterson Excel Discussion (Misc queries) 1 September 23rd 05 02:10 PM
Copy empty cells from one workbook to another - Code David Choen Excel Programming 0 September 22nd 05 01:01 PM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? Steven Rosenberg Excel Programming 0 August 5th 03 06:10 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


All times are GMT +1. The time now is 11:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"