J
John Pierce
The following procedure works perfectly when the commented line is used
but when I try to use the Inputbox I get an error: "Ojbect required."
It turns out that the list may not start at the same place everytime
and there may be blanks or gaps. I tried to learn about the Inputbox
Method from the sample code at the bottom, which is from a book, but I
can't get it to work either. Any help would be appreciated.
Public Sub RunReports()
Dim vManagers As Range, vManager As Range, DataArray(5)
Windows("DataTable.xls").Activate
'Set vManagers = Range(Cells(23, "D"), Cells(Rows.Count,
"D").End(xlUp))
Set vManagers = Application.InputBox("Use the mouse to select all
manager names in Column D", "Select Range", , , , , , 8)
On Error Resume Next
For Each vManager In vManagers
If vManager.Value = "S. O' Neil" Then
vManager.Activate
DataArray(1) = ActiveCell.Offset(0, -3)
DataArray(2) = ActiveCell.Offset(0, -1)
DataArray(3) = ActiveCell.Offset(0, 1)
DataArray(4) = ActiveCell.Offset(0, 3)
DataArray(5) = ActiveCell.Offset(0, 7)
Windows("Check Deposit Report.xls").Activate
Sheets("CHECK-DEPOSIT").Copy After:=Sheets(1)
ActiveSheet.Unprotect
Range("F43").Value = DataArray(1)
Range("B43").Value = DataArray(2)
Range("F32").Value = DataArray(3)
Range("A43").Value = DataArray(4)
Range("I27").Value = -DataArray(5)
Windows("DataTable.xls").Activate
End If
Next
Windows("Check Deposit Report.xls").Activate
End Sub
Sub GetRange()
Dim UserRange As Range
Default = Selection.Address 'Assignment to constant not permitted.
On Error GoTo Canceled
Set UserRange = Application.InputBox(prompt:="Range to erase:",
Title:="Range Erase", Default:=Default, Type:=8)
UserRange.Clear
UserRange.Select
Canceled:
End Sub
but when I try to use the Inputbox I get an error: "Ojbect required."
It turns out that the list may not start at the same place everytime
and there may be blanks or gaps. I tried to learn about the Inputbox
Method from the sample code at the bottom, which is from a book, but I
can't get it to work either. Any help would be appreciated.
Public Sub RunReports()
Dim vManagers As Range, vManager As Range, DataArray(5)
Windows("DataTable.xls").Activate
'Set vManagers = Range(Cells(23, "D"), Cells(Rows.Count,
"D").End(xlUp))
Set vManagers = Application.InputBox("Use the mouse to select all
manager names in Column D", "Select Range", , , , , , 8)
On Error Resume Next
For Each vManager In vManagers
If vManager.Value = "S. O' Neil" Then
vManager.Activate
DataArray(1) = ActiveCell.Offset(0, -3)
DataArray(2) = ActiveCell.Offset(0, -1)
DataArray(3) = ActiveCell.Offset(0, 1)
DataArray(4) = ActiveCell.Offset(0, 3)
DataArray(5) = ActiveCell.Offset(0, 7)
Windows("Check Deposit Report.xls").Activate
Sheets("CHECK-DEPOSIT").Copy After:=Sheets(1)
ActiveSheet.Unprotect
Range("F43").Value = DataArray(1)
Range("B43").Value = DataArray(2)
Range("F32").Value = DataArray(3)
Range("A43").Value = DataArray(4)
Range("I27").Value = -DataArray(5)
Windows("DataTable.xls").Activate
End If
Next
Windows("Check Deposit Report.xls").Activate
End Sub
Sub GetRange()
Dim UserRange As Range
Default = Selection.Address 'Assignment to constant not permitted.
On Error GoTo Canceled
Set UserRange = Application.InputBox(prompt:="Range to erase:",
Title:="Range Erase", Default:=Default, Type:=8)
UserRange.Clear
UserRange.Select
Canceled:
End Sub