?
Solved

Ignore statement

Posted on 2014-03-05
3
Medium Priority
?
236 Views
Last Modified: 2014-03-10
I am using the following piece of code which works fine when there is data to collect

strRange = Left(strRange, Len(strRange) - 1)
.Range(strRange).Copy

But it falls over with the statement 'Invalid procedure call or argument' when there is no data.

Could an expert out there provide me with the code that will move the code past this so that it does not fall over when there is no data

Thanks
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
regmigrant earned 1600 total points
ID: 39906744
before the line that fails you can put 'on error resume next' if you know this is the only reason for the error.

its usually better to code around this sort of thing though by checking to see if the range is available. for example the following makes sure that strrange is at least 2 characters before trying to shorten it (your code should be trying to prove its a valid range as well)

If strRange > 2 then    
 strRange = Left(strRange, Len(strRange) - 1)
   .range(...
Endif
0
 
LVL 39

Assisted Solution

by:nutsch
nutsch earned 400 total points
ID: 39906817
I agree with regmigrant on the approach, but he most likely intended his code to be the following (with the len() function):

If len(strRange) > 2 then    
 strRange = Left(strRange, Len(strRange) - 1)
   .range(...
Endif 

Open in new window


Thomas
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39907999
d'oh, thanks for the catch
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

801 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