Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Shorten VBA to one statement instead of three?

Posted on 2014-10-08
6
Medium Priority
?
102 Views
Last Modified: 2014-10-08
Is there a way to combine Ln2 thru 4?  I do not believe I have to select the sheet tab each time as long as it is active.  I just want to put the value collected for Ln1 in a specific cell location on a specific sheet tab.

    MatlDescValue = session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP02/ssubTABFRA1:SAPLMGMM:2004/subSUB1:SAPLMGD1:1002/txtMAKT-MAKTX").Text 'Matl Description
    Sheets("BasicData1").Select
    Range("B5").Select
    ActiveCell.FormulaR1C1 = MatlDescValue

Open in new window

0
Comment
Question by:RWayneH
[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
  • 4
  • 2
6 Comments
 
LVL 27

Expert Comment

by:ProfessorJimJam
ID: 40368382
Sheets("BasicData1").Range("B5").Select
0
 
LVL 27

Expert Comment

by:ProfessorJimJam
ID: 40368385
     MatlDescValue = session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP02/ssubTABFRA1:SAPLMGMM:2004/subSUB1:SAPLMGD1:1002/txtMAKT-MAKTX").Text 'Matl Description
    Sheets("BasicData1").Range("B5").Select
    ActiveCell.FormulaR1C1 = MatlDescValue

Open in new window

0
 
LVL 27

Accepted Solution

by:
ProfessorJimJam earned 2000 total points
ID: 40368389
i did not read your question correctly.

now here you go.  to put them all in one line see code below


 Sheets("BasicData1").Range("B5").Value = session.findbyid("wnd[0]/usr/tabsTABSPR1/tabpSP02/ssubTABFRA1:SAPLMGMM:2004/subSUB1:SAPLMGD1:1002/txtMAKT-MAKTX").Text 'Matl Description

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RWayneH
ID: 40368395
Does it have to select B5?  Could I do something like:
Sheets("BasicData1").Range("B5") = MatlDescValue    ?  I just would like to eliminate lines that are not needed.
0
 
LVL 27

Expert Comment

by:ProfessorJimJam
ID: 40368400
the last code i posted, is not selecting anything. it is using the ".Value" Property .

you cannot use Sheets("BasicData1").Range("B5") = MatlDescValue

instead you can use

Sheets("BasicData1").Range("B5").Value = MatlDescValue
0
 

Author Closing Comment

by:RWayneH
ID: 40368424
Yup worked great...   I need to focus on combining lines of code... speeds up the process and makes them easy to read.
THANKS!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

715 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