D
Dan
I need help!
I have a database workbook, a xla file (soon to be) that contains a listbox,
and a data input workbook. Using the listbox from the xla file, I need to
populate the input file from the database file. I'm close, but cannot get to
the last step. I am using a 'right click' menu item to fire the code below.
It works if I am on the database file, but not on the input file.
What am I missing?
The database workbook will be updated frequently but must it be opened to be
used?
Thanks in advance!
Sub See_Vendor()
wbname = "Current Vendors"
Call WorkbookIsOpen(wbname)
If Err <> 0 Then
Workbooks.Open Filename:="s:\finance\acct-gl\current vendors.xls"
Range("a2").Select
Top = ActiveCell.Address
Selection.End(xlDown).Select
ActiveCell.Offset(0, 3).Select
bottom = ActiveCell.Address
Worksheets("Sheet1").Range(Top, bottom).Name = "Vendor"
End If
Vendor_Lookup.Show
End Sub
Function WorkbookIsOpen(wbname) As Boolean
'Used from John Walkenbach's VBA Power Programming
'Returns True if the workbook is open
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else WorkbookIsOpen = False
End Function
Private Sub UserForm_Initialize()
ListBox1.RowSource = "Vendor"
End Sub
I have a database workbook, a xla file (soon to be) that contains a listbox,
and a data input workbook. Using the listbox from the xla file, I need to
populate the input file from the database file. I'm close, but cannot get to
the last step. I am using a 'right click' menu item to fire the code below.
It works if I am on the database file, but not on the input file.
What am I missing?
The database workbook will be updated frequently but must it be opened to be
used?
Thanks in advance!
Sub See_Vendor()
wbname = "Current Vendors"
Call WorkbookIsOpen(wbname)
If Err <> 0 Then
Workbooks.Open Filename:="s:\finance\acct-gl\current vendors.xls"
Range("a2").Select
Top = ActiveCell.Address
Selection.End(xlDown).Select
ActiveCell.Offset(0, 3).Select
bottom = ActiveCell.Address
Worksheets("Sheet1").Range(Top, bottom).Name = "Vendor"
End If
Vendor_Lookup.Show
End Sub
Function WorkbookIsOpen(wbname) As Boolean
'Used from John Walkenbach's VBA Power Programming
'Returns True if the workbook is open
Dim x As Workbook
On Error Resume Next
Set x = Workbooks(wbname)
If Err = 0 Then WorkbookIsOpen = True _
Else WorkbookIsOpen = False
End Function
Private Sub UserForm_Initialize()
ListBox1.RowSource = "Vendor"
End Sub