R
RompStar
Dave :- ), everyone :- )
Ok, imagine a excel sheet, has columns A to O
column Names/Headers are at A9:O9
at A10:O10 raw data...
So the user enters the dates, this time from column A,
START DATE
END DATE,
I need help to feed that collected data to the last part, see code...
can anyone help me out.. ? that part of the code works, but I have to
select with a mouse, I would rather have the user enter the date range
and then it automatically print it, because there is a lot of ROWS,
like 3000 and counting...
Sub PrintRange()
Dim LastRow As Long
Dim Rng As Range
Dim Msg As Integer
Dim BeginDate As Date
Dim EndDate As Date
Dim c As Range
Dim Item As Range
LastRow = Range("A10").End(xlDown).Row
Set Rng = Range("A10" & Range("A65536").End(xlUp).Row)
Do
Msg = vbOK
BeginDate = Application.InputBox("Enter Starting Date from
column A:", "Range Beginning", Type:=1)
If Not IsDate(BeginDate) Then
' Checks to see if entry is a date
Msg = MsgBox("Entry not a valid date!", vbCritical +
vbRetryCancel, "Error: Invalid Date")
End If
' Converts to date format
BeginDate = DateValue(BeginDate)
Loop While Msg = vbRetry
Do
Msg = vbOK
EndDate = Application.InputBox("Enter Ending Date from column
A:", "Range Ending", Type:=1)
If Not IsDate(EndDate) Then
Msg = MsgBox("Entry not a valid date!", vbCritical +
vbRetryCancel, "Error: Invalid Date")
End If
EndDate = DateValue(EndDate)
Loop While Msg = vbRetry
MsgBox "You selected: " & BeginDate & " through " & EndDate & " ", ,
"Select Range"
' Pass the selected Range to the code below, not sure how yet :- )
On Error GoTo Finish
' --------------------------
Worksheets("Master").Activate
Set myRange = Application.InputBox( _
Prompt:="Select a Range to print!" & Chr(13) & Chr(13) & "Use your
mouse!" & Chr(13) _
& "For more than one Range add a ""comma"" between your selected
Ranges!", Type:=8)
myRange.Select
MsgBox "Ready to print: " & Selection.Address
ActiveSheet.PageSetup.PrintArea = Selection.Address
ActiveSheet.PageSetup.FitToPagesWide = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Master").Range("A1").Select
Finish:
End Sub
Ok, imagine a excel sheet, has columns A to O
column Names/Headers are at A9:O9
at A10:O10 raw data...
So the user enters the dates, this time from column A,
START DATE
END DATE,
I need help to feed that collected data to the last part, see code...
can anyone help me out.. ? that part of the code works, but I have to
select with a mouse, I would rather have the user enter the date range
and then it automatically print it, because there is a lot of ROWS,
like 3000 and counting...
Sub PrintRange()
Dim LastRow As Long
Dim Rng As Range
Dim Msg As Integer
Dim BeginDate As Date
Dim EndDate As Date
Dim c As Range
Dim Item As Range
LastRow = Range("A10").End(xlDown).Row
Set Rng = Range("A10" & Range("A65536").End(xlUp).Row)
Do
Msg = vbOK
BeginDate = Application.InputBox("Enter Starting Date from
column A:", "Range Beginning", Type:=1)
If Not IsDate(BeginDate) Then
' Checks to see if entry is a date
Msg = MsgBox("Entry not a valid date!", vbCritical +
vbRetryCancel, "Error: Invalid Date")
End If
' Converts to date format
BeginDate = DateValue(BeginDate)
Loop While Msg = vbRetry
Do
Msg = vbOK
EndDate = Application.InputBox("Enter Ending Date from column
A:", "Range Ending", Type:=1)
If Not IsDate(EndDate) Then
Msg = MsgBox("Entry not a valid date!", vbCritical +
vbRetryCancel, "Error: Invalid Date")
End If
EndDate = DateValue(EndDate)
Loop While Msg = vbRetry
MsgBox "You selected: " & BeginDate & " through " & EndDate & " ", ,
"Select Range"
' Pass the selected Range to the code below, not sure how yet :- )
On Error GoTo Finish
' --------------------------
Worksheets("Master").Activate
Set myRange = Application.InputBox( _
Prompt:="Select a Range to print!" & Chr(13) & Chr(13) & "Use your
mouse!" & Chr(13) _
& "For more than one Range add a ""comma"" between your selected
Ranges!", Type:=8)
myRange.Select
MsgBox "Ready to print: " & Selection.Address
ActiveSheet.PageSetup.PrintArea = Selection.Address
ActiveSheet.PageSetup.FitToPagesWide = 1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Master").Range("A1").Select
Finish:
End Sub