Results 1 to 3 of 3

How to make variables reference different cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-20-2017
    Location
    Indiana
    MS-Off Ver
    2016
    Posts
    101

    How to make variables reference different cells

    I'm trying to make some variables reference different cells as the code loops through. I'm just not sure how to format the i variable into existing variables. For example, I'm trying to make the WBS variable reference A2 the first loop through. Then A3 the second loop through and so on.

    'SAP inputs
    i = 0
    WBS = Range("A2+i")
    Month = Range("B2")
    Year = Range("C2")
    Name = Range("D2+i")
    '
    Do While i < 2
        session.findById("wnd[0]/usr/ctxtP_POSID").Text = WBS 'WBS var
        session.findById("wnd[0]/usr/ctxtP_PERIO").Text = "1"
        session.findById("wnd[0]/usr/txtP_GJAHR").Text = "1900"
        session.findById("wnd[0]/usr/ctxtP_TPERIO").Text = Month 'Month var
        session.findById("wnd[0]/usr/txtP_TGJAHR").Text = Year 'Year var
        session.findById("wnd[0]/usr/txtP_TGJAHR").SetFocus
        session.findById("wnd[0]/usr/txtP_TGJAHR").caretPosition = 4
        session.findById("wnd[0]").sendVKey 8
        session.findById("wnd[0]/usr/lbl[8,7]").SetFocus
        session.findById("wnd[0]/usr/lbl[8,7]").caretPosition = 9
        session.findById("wnd[0]/tbar[1]/btn[47]").press
        session.findById("wnd[0]/mbar/menu[4]/menu[5]/menu[2]/menu[1]").Select
        session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").Select
        session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").SetFocus
        session.findById("wnd[1]/tbar[0]/btn[0]").press
        session.findById("wnd[1]/usr/ctxtDY_PATH").SetFocus
        session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 0
        session.findById("wnd[1]").sendVKey 4
    
    'Save file
        session.findById("wnd[2]/usr/ctxtDY_FILENAME").Text = Name & ".xls" 'Name var
        session.findById("wnd[2]/usr/ctxtDY_FILENAME").caretPosition = 11
        session.findById("wnd[2]/tbar[0]/btn[0]").press
        session.findById("wnd[1]/tbar[0]/btn[0]").press
    
    'Back to transaction
        session.findById("wnd[0]").sendVKey 3
    '
        i = i + 1
    Loop
    Last edited by BryceVBA; 04-26-2017 at 10:36 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How can I make absolute reference only cells that referenced from another sheet??
    By marins0330 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2017, 09:01 AM
  2. How to make a formula dynamically reference another set of cells?
    By ShootingBlanks in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-22-2016, 04:59 PM
  3. Replies: 3
    Last Post: 02-27-2014, 02:31 PM
  4. Replies: 0
    Last Post: 03-08-2013, 06:34 AM
  5. how to make 3 cells as reference to each other
    By KALATRASH81 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-04-2013, 03:41 AM
  6. Replies: 3
    Last Post: 07-16-2009, 12:40 AM
  7. [SOLVED] Can I link cells to a reference table I make?
    By EZimm in forum Excel General
    Replies: 1
    Last Post: 05-04-2005, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1