Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem to the line

Posted on 2015-02-09
4
Medium Priority
?
92 Views
Last Modified: 2015-02-09
Hi,
The original Excel file is version 2003, after I've re-saved it as Excel 2010 macro-enabled version, and then tried to run the macro, I get the attached problem, due to this line

        Range(objShtDst.Cells(intcurdstrow, 2), objShtDst.Cells(intcurdstrow, 6)).Select

Open in new window


why?
t968.png
0
Comment
Question by:HuaMinChen
[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
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40597852
in a macro, you rarely need to actually "select" the range, but rather use the range object.
meaning that instead of doing:
range.Select
selection.dosomething

you do
range.dosomething
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 40597862
Thanks. It has codes like

        Range(objShtDst.Cells(intcurdstrow, 2), objShtDst.Cells(intcurdstrow, 6)).Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlEdgeLeft).LineStyle = xlNone
        Selection.Borders(xlEdgeTop).LineStyle = xlNone
...

Open in new window


how to correct the problem to 1st line in above?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1200 total points
ID: 40597885
this should not only work without the error, but will also run faster:
dim r as Range
set r =  Range(objShtDst.Cells(intcurdstrow, 2), objShtDst.Cells(intcurdstrow, 6))
        r.Borders(xlDiagonalDown).LineStyle = xlNone
        r.Borders(xlDiagonalUp).LineStyle = xlNone
        r.Borders(xlEdgeLeft).LineStyle = xlNone
        r.Borders(xlEdgeTop).LineStyle = xlNone

Open in new window

0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 300 total points
ID: 40597902
It's also better to qualify the Range call:

set r =  objShtDst.Range(objShtDst.Cells(intcurdstrow, 2), objShtDst.Cells(intcurdstrow, 6))

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

618 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