Selección Área Impresión seleccionando dos celdas

Hola Tengo una macro general pero dentro de esta macro quiero incluir otra que me seleccione el área de impresión. En primera instancia selecciono la celda inicial y en segunda instancia selecciono la otra celda y al finalizar toma las dos coordenadas y marca el área de impresión. El problema esta en que no se como interrumpir la ejecución del macro para seleccionar cada celda.

Option Explicit
Dim a, b, i As Variant

Sub GeneralAreaImpresion()
Call Celda1AreaImpresion
Call Celda2AreaImpresion
ActiveSheet.PageSetup.PrintArea = (a & ":" & b)
End Sub

Sub Celda1AreaImpresion()
MsgBox "Seleccione la Celda Inicial del Área de Impresión"
For i = 1 To 100000000
Next
a = ActiveCell.Address
MsgBox "La celda es" & a
End Sub

Sub Celda2AreaImpresion()
MsgBox "Seleccione la Celda Final del Área de Impresión"
For i = 1 To 100000000
Next
b = ActiveCell.Address
MsgBox "La celda es" & b
End Sub

Respuesta
1

En lugar de un MsgBox utilizá un InputBox con opción de seleccionar celda.

En este ejemplo, luego de solicitar la 1ra t 2da celda selecciona el rango.

Sub buscarango()
'x Elsamatilde
Dim rgo As Range
On Error Resume Next
Set rgo = Application.InputBox("selecciona la 1er celda", Type:=8)
If Not rgo Is Nothing Then
a = rgo.Address
End If
Set rgo = Application.InputBox("selecciona la 2da celda", Type:=8)
If Not rgo Is Nothing Then
b = rgo.Address
End If
Range(a & ":" & b).Select
End Sub

PD) Todo lo relacionado a MsgBox e InputBox lo podrás encontrar en mi manual Formularios.

Elsa muchas gracias por la indicación, me sirvio de mucho. Tengo otra consulta pero no pertenece a este tema.

Cuando intento quitar el pie de pagina ejecuntando una macro no me quita dicho pie de pagina, pero cuando ejecuto la macro paso a paso si quita el pie de pagina....

El objeto de esa actividad es que tengo que hacer esa operacion muchas veces y por eso el objeto de esa macro.

Y por ultimo como puedo unir el codigo anterior en esta macro.

Sub Encabezado()
'
' Encabezado Macro
'
'
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$B$4:$O$40"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.LeftFooter = ""
.LeftFooter = ""
.LeftFooter = ""
For i = 1 To 10000000
Next
.CenterFooter = ""
.CenterFooter = ""
.CenterFooter = ""
.CenterFooter = ""
For i = 1 To 10000000
Next
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.62992125984252)
.RightMargin = Application.InchesToPoints(0.62992125984252)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0.78740157480315)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 65
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = False
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
End Sub

Disculpa pero solo se puede tratar un tema por vez.

Cuando finalices ésta, deja las 2 nuevas cada una con su título correspondiente en el tablón y con mucho gusto me ocuparé.

Sdos

Elsa

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas