+ Reply to Thread
Results 1 to 4 of 4

value recalled from cell cannot be used in formula

Hybrid View

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    value recalled from cell cannot be used in formula

    I recalled a value from a cell in a worksheet and VBA is telling me that it cannot use it. It automatically renamed it and I don't know why. Here is my code:

    'Calculate K factor for fill valve
        If valve_type = "Ball" Then K = Worksheets("Sheet1").Cells(1, 3).Value
        If valve_type = "Globe" Then K = Worksheets("Sheet1").Cells(2, 3).Value
        If valve_type = "Butterfly" Then K = Worksheets("Sheet1").Cells(3, 3).Value
        
        
        'Calculate headloss in fill valve
        hl_fillvalve = K * Colebrook_equation_fillvalve * T_exit_velocity ^ 2 / 2
    It renames the 'K' variable to 'K-factor'. I do not have a variable named 'K-factor' anywhere. How can I fix this?

    Thanks
    Last edited by damayn83; 01-21-2013 at 11:01 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: value recalled from cell cannot be used in formula

    What is "K" declared as at the top of your macro?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    Re: value recalled from cell cannot be used in formula

    I dimensioned "K" as single and the problem is still occuring. very confusing.

  4. #4
    Registered User
    Join Date
    01-18-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    MS Office 2010
    Posts
    25

    Re: value recalled from cell cannot be used in formula

    I was able to fix it. Had to correct what cells the program was refferencing. Completely overlooked that fact.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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