Macro para copiar información de un documento a otro pero no permite escoger otra hoja diferente a la actual.
Tengo esta macro la cual permite abrir un documento y seleccionar la cantidad de columnas que quiero copiar y pegar en un documento totalmente nuevo. El problema que tengo es que si el documento destino tiene más de una hoja solo permite tomar la hoja actual pero quiero que al abrirlo me permita seleccionar la hoja que yo desee y una vez seleccionada ahí si proceda con el resto de la macro (pedir cantidad de columnas, seleccionarlas, copiarlas, pegarlas en el nuevo documento, reemplazar los valores y terminar la macro)
Sub move_data()
Dim data_wb As Workbook
Dim target_wb As Workbook
Dim file_name As Variant
Dim header_range(100) As Range
Dim last_row As Long
Dim col_number As Long
Dim col_letter As String
Dim counter As Long
Dim quantity As Long
'select workbook
file_name = Application.GetOpenFilename(Title:="Choose a target Workbook")
If file_name <> False Then
'create a new target workbook
Set target_wb = Application.Workbooks.Add
'open Workbook with the data
Set data_wb = Application.Workbooks.Open(file_name)
'get quantity to create loop
quantity = _
InputBox("How many columns do you want to copy?")
'loop
For counter = 1 To quantity
'select header range
Set header_range(counter) = _
Application.InputBox("Select the HEADER of the " & counter & "º column you want to copy", Type:=8)
'get last row and col letter
col_number = header_range(counter).Column
last_row = Cells(Rows.Count, col_number).End(xlUp).Row
col_letter = Split(Cells(1, col_number).Address(True, False), "$")(0)
'copy from data_wb
Range(header_range(counter), Range(col_letter & last_row)).Copy
'pastein target_wb
target_wb.Sheets("Sheet1").Cells(1, counter).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Next counter
Application.CutCopyMode = False
End If
target_wb.Sheets("Sheet1").Cells.Replace What:="NBCU Id", Replacement:="NBCU ID"
target_wb.Sheets("Sheet1").Cells.Replace What:="Channel", Replacement:="ChannelName"
target_wb.Sheets("Sheet1").Cells.Replace What:="Content Title", Replacement:="Show"
target_wb.Sheets("Sheet1").Cells.Replace What:="Season#", Replacement:="Season"
target_wb.Sheets("Sheet1").Cells.Replace What:="Episode#", Replacement:="Eps"
target_wb.Sheets("Sheet1").Cells.Replace What:="License Start Date", Replacement:="VOD Start"
target_wb.Sheets("Sheet1").Cells.Replace What:="License End Date", Replacement:="VOD End"
target_wb.Sheets("Sheet1").Cells.Replace What:="E!", Replacement:="E"
target_wb.Sheets("Sheet1").Cells.Replace What:="Studio", Replacement:="STUDIO"
target_wb.Sheets("Sheet1").Cells.Replace What:="SyFy", Replacement:="SYFY"
target_wb.Sheets("Sheet1").Cells.Replace What:="Telemundo Internacional", Replacement:="TELEMUNDO INTERNACIONAL"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal TV", Replacement:="UTV"
target_wb.Sheets("Sheet1").Cells.Replace What:="DreamWorks", Replacement:="DREAMWORKS"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal Cinema", Replacement:="Cinema"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal Comedy", Replacement:="Comedy"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal Crime", Replacement:="Crime"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal Premiere", Replacement:="Premiere"
target_wb.Sheets("Sheet1").Cells.Replace What:="Universal Reality", Replacement:="Reality"
target_wb.Sheets("Sheet1").Range("A1:H1").Name = "Print_Area"
lastCol = target_wb.Sheets("Sheet1").Range("A2").End(xlToRight).Column
lastRow = target_wb.Sheets("Sheet1").Cells(target_wb.Sheets("Sheet1").Rows.Count, lastCol).End(xlUp).Row
target_wb.Sheets("Sheet1").Range("A2", target_wb.Sheets("Sheet1").Cells(lastRow, lastCol)).Name = "vodoffer"
target_wb.Sheets("Sheet1").Name = "Detail"
target_wb.Sheets.Add
target_wb.Sheets("Sheet2").Name = "Product"
target_wb.Sheets("Product").Range("A1").Value = InputBox("Write the type of product: Basic or Premium")
End Sub
Adicionalmente, me gustaría que una vez se acabe de correr la macro me salga la ventana de guardar este nuevo documento que crea de ceros y el nombre del archivo sea el que está en la celda A1 del documento y hoja destino y se pueda guardar ahí con el aceptar de la venta de guardar como.
Mil gracias de antemano.