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: 536
Default Similar Book to Book Code, one works other does not

Thanks to Claus for these two codes.
Normally you would have the "Copy WkBook To" open and both codes work well.

I added the open "Copy WkBook To" code line to both so that you would not have to open it manually, the code would do it.

Sub CopyBookToBookClaus_Rangex() works just fine.

Sub CopyBookToBook2Claus_ColLetterx() opens the other workbook but does not complete the column copy after entering a destination column letter in the second InPut prompt.

What am I missing here?

Thanks.
Howard


Option Explicit

Sub CopyBookToBookClaus_Rangex()

Dim ColRngFrm As Range
Dim ColRngTo As Range

Set ColRngFrm = Application.InputBox(Prompt:="Enter a Copy from Range.", _
Title:="Enter Copy from Column", Type:=8)
If ColRngFrm Is Nothing Then Exit Sub

Workbooks.Open Filename:= _
"C:\Users\Howard Kittle\Documents\Copy WkBook TO.xlsm"
Application.Goto Workbooks("Copy WkBook To").Sheets("Sheet1").Range("A1")

Set ColRngTo = Application.InputBox(Prompt:="Enter a Copy to Range.", _
Title:="Enter Copy to Column", Type:=8)
If ColRngTo Is Nothing Then Exit Sub

MsgBox ColRngTo.Address

ColRngFrm.Copy ColRngTo

End Sub



Sub CopyBookToBook2Claus_ColLetterx()

Dim ColRngFrm As String
Dim ColRngTo As String
Dim LRow As Long

LRow = Cells(Rows.count, 1).End(xlUp).Row

ColRngFrm = Application.InputBox(Prompt:="Enter a column letter.", _
Title:="Enter a column letter", Type:=2)
If ColRngFrm = "" Or ColRngFrm = "False" Then Exit Sub

Workbooks.Open Filename:= _
"C:\Users\Howard Kittle\Documents\Copy WkBook TO.xlsm"
Application.Goto Workbooks("Copy WkBook To").Sheets("Sheet1").Range("A1")

ColRngTo = Application.InputBox(Prompt:="Enter a column letter.", _
Title:="Enter a column letter", Type:=2)
If ColRngTo = "" Or ColRngTo = "False" Then Exit Sub

Range(Cells(1, ColRngFrm), Cells(LRow, ColRngFrm)).Copy _
Workbooks("Copy WkBook TO").Sheets("Sheet1").Cells(1, ColRngTo)


End Sub

 
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
Problem: Closing one book causes the 2nd book freeze fred Excel Programming 0 June 15th 09 03:09 AM
copy worksheets to new book without linking to original book Lori Excel Discussion (Misc queries) 2 March 4th 09 04:46 PM
to disconnect a destination book from a source book officegirl Excel Discussion (Misc queries) 4 December 10th 07 09:28 PM
'BeforeClose' code problems:book won't close if more than one book is open Ed from AZ Excel Programming 0 September 18th 07 03:59 PM
Open book, check for macros, close book Robin Hammond[_2_] Excel Programming 5 March 31st 05 06:09 PM


All times are GMT +1. The time now is 11:55 AM.

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"