LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Lilivati
 
Posts: n/a
Default subscript out of range error in excell

I am trying to work with two workbooks, with workbook A looking up
information in workbook B. When workbook A opens it prompts the user
to open workbook b:

Public modelfile As String
Public nassisfile As String

'on open event for workbook A
Sub Workbook_Open()

modelfile = ThisWorkbook

If nassisfile = "" Then
MsgBox "Please open a NASSIS reference file."
nassisfile = Application.GetOpenFilename("Excel Files,*.xls", 1,
"Select a NASSIS file.")
Workbooks.Open nassisfile
Workbooks(modelfile).Activate
End If

End Sub


This part works perfectly. The reference file (workbook B) opens as
instructed and workbook A is reactivated.

Then in the worksheet change event for workbook A I have the following:

Sub Worksheet_Change(ByVal Target As Range)
Dim Val As Range
Dim cell As Range
Dim part As String
Dim desc As String
Dim mlUsed As Range
Dim msg As String

'here is where the error occurs
Set mlUsed = Workbooks("nassisfile").Worksheets(2).Range("C:D")


Set Val = Range("B:B")

For Each cell In Target
If Union(cell, Val).Address = Val.Address And cell.text < "" Then
part = cell.text
desc = WorksheetFunction.VLookup(part, mlUsed, 2, False)
cell.Offset(0, 2) = desc
End If
Next cell

End Sub

Now workbook B (nassisfile) definitely exists- the user just opened it!
Yet I am getting this error. This is very frustrating as this code
worked perfectly when I left it on Friday, and when I solved a
different problem today it no longer works. I eliminated all the
changes I made today and it still will not function. Please help!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
How do I advance the range by one row Excell VBA automatically Eric Excel Discussion (Misc queries) 1 January 28th 05 06:11 PM
How do I advance the range by one row Excell VBA automatically Eric Excel Discussion (Misc queries) 0 January 28th 05 05:47 PM


All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"