+ Reply to Thread
Results 1 to 8 of 8

Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

  1. #1
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    So in its most basic form I'm trying to do this:
    Please Login or Register  to view this content.
    Where i, j, and k are loops going through the different column values. (this is easier to read than the below)

    I've also tried:
    Please Login or Register  to view this content.
    Either way gives me a 424 error code - Object required.

    How do I properly access the cell values with the defined column and variable row?

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    Cell is a string, it doesn't have a Formula property.

    Why not try Cells(i, "AG").Formula = "..."?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    Ah, that was definitely one of my problems. Now I'm getting a 1004 error - application defined or object defined error - still a problem with how I'm trying to access these cells.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    The problem is with the formula.

    Admittedly I've not had a close look at it but one thing that doesn't look right is that you appear to be trying to use & as a logical operator.

    What should the formula look like in a cell?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    Just checked the formula and though I still think the & is a problem what's actually causing the error is the spaces you have between column and row.

    This won't cause any errors but I'm not sure the formula will do what you want.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    That did solve the error - thanks!

    This would be an example of one instance -

    "=IF(AE3=AD3 & AC3=AA3, AB3+AF3,"")"
    So yes I am using the &, so that both AE3=AD3 and AC3=AA3 have to be true in order for the cell to take the value (AB3+AF3).

    I think you're right in that being the problem as I just set them both to be true, but got back a False answer.

    Is there a way for Excel to accept two logical tests? I suppose I could do each one, output a 1 or 0 to two additional columns, then compare them?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    In Excel & is the concatenation operator, if you want logical And then you need to use the AND function.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    By the way, where are you putting this formula?

  8. #8
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Accessing variables in VBA via formulas from the spreadsheet (assigned by VBA)

    Ah wow, well that was probably a huge part of the problem that shouldn't have been *palm to face*. Thanks!

    The function is showing up now, but not how I intended. I'll *TRY* to explain my larger problem - with fear that it will scare you away!

    Attached is an example of the data I'm using (I left them starting at column AA) - below is the code I am trying to use to get the desired effect.

    But first - the two columns AC and AD are my "translation" list - think of it as if you were trying to convert spanish to english. (el or la = the, etc. - it isn't necessarily a one to one exchange). The list D_master_keys is the "language" I want to get it to, and D_LP_keys is the "language" I'm translating.

    Anyway, for each D_LP_key I want to translate it to the D_Master_key - then add the values associated with them.
    I tried doing this with dictionaries, as that's what they originally were, but to no avail. Here is that thread.

    Please Login or Register  to view this content.
    If you have any guidance on direction that might be helpful, it would be appreciated. Thanks for all your help so far!
    Attached Files Attached Files

+ 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. Need Variables assigned, thats all Please
    By keen2xl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2013, 12:27 PM
  2. Accessing values of 'alphanumeric' variables
    By deadlyduck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-03-2010, 02:53 PM
  3. Accessing variables assigned in one userform by a second userform?
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2009, 04:12 PM
  4. Accessing Variables In Modules
    By Programmin'Pete in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-30-2009, 04:19 AM
  5. [SOLVED] Values assigned to variables staying in memory when procedure stop
    By Peter Rooney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2005, 11:05 AM

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