Solved

VBA Excel - Runtime Error 438

Posted on 2014-10-31
2
1,921 Views
Last Modified: 2014-10-31
Hi,

I have this code for which I'm trying to define a range to search in, but it gives me the runtime error above.  

What I'm trying to accomplish is to open ANOTHER spreadsheet, search for a value and paste other values based on that.

 
   Dim wb As Workbook
    
    Set wb = Workbooks.Open("c:\Original.xlsx")
    Set ws2 = wb.Sheets("FS_ITEM") 

    With ws2(1).Range("a2:amq2")

Open in new window


I've tried a smaller range, different sheets, books etc.  Must be something I've overlooked.

tnx
~j
0
Comment
Question by:prosit
2 Comments
 
LVL 5

Accepted Solution

by:
ReneD100 earned 500 total points
ID: 40415570
ws2 is a workbook object. This object does not have an index so ws2(1) does not make any sense. ws2.range("a2:amq2") should work.
0
 
LVL 2

Author Closing Comment

by:prosit
ID: 40415601
yes yes :)

thank you!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now