+ Reply to Thread
Results 1 to 7 of 7

pass value from vba to excell spreadsheet

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    texas usa
    MS-Off Ver
    Excel 2010
    Posts
    70

    pass value from vba to excell spreadsheet

    I have vba code that gets a value for Lrow such as 300. I want to pass this value to the spreadsheet
    so it can be used such as a variable in a formula
    such as a formula in cell d23 =Lrow+45

    Thanks carroll

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: pass value from vba to excell spreadsheet

    There are 29 ways to do this, depending on what you are trying to achieve. Here's one:

    Please Login or Register  to view this content.
    A
    B
    C
    1
    2
    43
    3
    37
    59
    B3: =lRow + 45
    4
    3
    5
    97
    6
    12
    7
    96
    8
    92
    9
    67
    10
    48
    11
    26
    12
    100
    13
    94
    14
    8
    15
    16
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-10-2012
    Location
    texas usa
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: pass value from vba to excell spreadsheet

    Thanks SHG You gave a good example. I can now use ActiveSheet.Range("Q2").Value = lRow to
    to put lrow in cell q2 in the spreadsheet.

    My challenge now is to use this lrow value in a formula that uses a range, like

    ,=IFERROR(LOOKUP(1,-SEARCH($IG$6:$IG$2190,$IJ7),$II$6:$II$2190)," ")
    where I need to replace 2190 with a reference to a cell containing the lrow value
    for example if I use ActiveSheet.Range("IG2").Value = lRow then the formula above
    might look like
    ,=IFERROR(LOOKUP(1,-SEARCH($IG$6:$IG$&(ig2),$IJ7),$II$6:$II$&(ig2))," ")
    However this does not work and I have been unsuccessful in replacing the 2190
    with a reference to the lrow value in IG2 which changes with different sets of data.
    Thanks for your help Carroll

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: pass value from vba to excell spreadsheet

    Not tested but can you use Indirect i.e.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,522

    Re: pass value from vba to excell spreadsheet

    Change references where required
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-10-2012
    Location
    texas usa
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: pass value from vba to excell spreadsheet

    Worked great thanks much

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: pass value from vba to excell spreadsheet

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 10-13-2017, 12:01 PM
  2. How do I pass a textbox on a spreadsheet to a function
    By ucchris77 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-12-2010, 10:52 AM
  3. How to calculate pass/fail percentages entered on a spreadsheet?
    By Jenna in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-05-2006, 12:35 PM
  4. Pass date to cell in spreadsheet
    By cedtech23 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-02-2006, 12:55 PM
  5. [SOLVED] i cant get into excell spreadsheet
    By tony in forum Excel General
    Replies: 1
    Last Post: 09-14-2005, 05:05 PM
  6. [SOLVED] multiplication in an Excell Spreadsheet
    By KiaOra in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 02-20-2005, 04:06 PM
  7. excell spreadsheet
    By k.taylor in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-02-2005, 09:06 PM

Tags for this Thread

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