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: 25
Default copy to another wb and name the target sheet (XL2000)

Thanks for the reply Ron de Bruin and Bernie,
I want to apologize for not being clear on my first post.

Ron de Bruin,
I thought that my code would allow me to name the target but instead (i
think)it allows me to choose the target worksheet.
Currently, with the sub below, I run the macro I get the Inputbox, I
give it a name but when I check the target there is no data and no name
on the sheet.

Bernie,
I hope this answers your questions.

thanks,
Robert

Sub copy_to_another_workbook()

Dim sourceRange As Range
Dim destrange As Range
Dim destWB As Workbook
Dim Lr As Long
Dim destSheet As String
Dim wksName As String

Application.ScreenUpdating = False

If bIsBookOpen("test_target.xls") Then
Set destWB = Workbooks("test_target.xls")
Else
Set destWB = Workbooks.Open("C:\Documents and
Settings\test_target.xls")
End If
wksName = Application.InputBox(prompt:="Copy to what sheet: ",
Type:=2)

If wksName = flase Then
'do nothing
Else
On Error GoTo eind

Lr = LastRow(destWB.Sheets("wksname")) + 1
Set sourceRange =
ThisWorkbook.Sheets("DATA_TEST").Range("A1:C10")
Set destrange = destWB.Sheets("wksName").Range("A" & Lr)
sourceRange.Copy
destrange.PasteSpecial xlPasteValues, , False, False
Application.CutCopyMode = False
destWB.Close True
Application.ScreenUpdating = True
End If
Exit Sub
eind:
Application.ScreenUpdating = True
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
What formula will copy the content & format of the target cell? razorman Excel Discussion (Misc queries) 2 May 11th 07 08:24 PM
Changing target sheet name wihtin a macro Jim G Excel Discussion (Misc queries) 2 January 30th 06 03:05 AM
HOW TO COPY XL2000 (XP) MACROS TO XL2002 (XP) will A Excel Discussion (Misc queries) 0 January 16th 06 06:48 PM
copy to another wb and name the target sheet (XL2000) robert burger Excel Programming 1 September 24th 04 04:40 PM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Excel Programming 3 July 1st 04 09:25 PM


All times are GMT +1. The time now is 09:31 AM.

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"