H
Howard
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
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