Solved

VBA Excel - Runtime Error 438

Posted on 2014-10-31
2
1,953 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

815 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

11 Experts available now in Live!

Get 1:1 Help Now