+ Reply to Thread
Results 1 to 7 of 7

Formula Showing, Need the Value Instead

Hybrid View

TrivialT Formula Showing, Need the... 10-30-2013, 09:51 AM
ragulduy Re: Formula Showing, Need the... 10-30-2013, 09:54 AM
TrivialT Re: Formula Showing, Need the... 10-30-2013, 10:05 AM
ragulduy Re: Formula Showing, Need the... 10-30-2013, 10:06 AM
TrivialT Re: Formula Showing, Need the... 10-30-2013, 10:08 AM
ragulduy Re: Formula Showing, Need the... 10-30-2013, 10:11 AM
TrivialT Re: Formula Showing, Need the... 10-30-2013, 10:17 AM
  1. #1
    Registered User
    Join Date
    10-28-2013
    Location
    Pennylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Formula Showing, Need the Value Instead

    Hello All,

    I have one minor issue that I need help with. After much research, I have found some code that I added to my very own coding to turn the "vlookup" formula that results in the range of cells into the actual value. The issue at hand is I now need to manipulate that code to automatically change the formulas in the cells to the values, without needing to drag a range in the excel worksheet. here is my coding. Thanks.

    Sub GetValuesFromClosedWorkbook(fPath As String, fName As String, Shname, OutputRge As String, _
        LookupVal As String, TableArryRge As String, LookupCol As Integer, rangeLkup As Integer)
    
        With ActiveSheet.Range(OutputRge)
            .Formula = "=VLOOKUP(" & LookupVal & ",'" & fPath & "[" & fName & "]" & Shname & _
                        "'!" & TableArryRge & "," & LookupCol & "," & rangeLkup & ")"
        End With
        
        
    End Sub
    Sub test()
    
    Dim fPath As String
    Dim fName As String
    Dim sName As String
    Dim destCell As String
    Dim lookupCell As String
    Dim lookupRange As String
    Dim lCol As Integer
    Dim beginpos As Long
    Dim x As Long
    Dim RowCount As Long
    
        RowCount = ActiveSheet.Range("D" & Rows.Count).End(xlUp).row
        beginpos = 2
        fPath = "T:\blah\billing\blah\Sblahaasfs\Test\"
        If Right(fPath, 1) <> "\" Then fPath = fPath & "\"
        lookupRange = "A2:I29"
        lCol = 9
        fName = "Master1.xlsx"
        sName = "Master1"
       
    Application.DisplayAlerts = False
       
        For x = beginpos To RowCount
        
            destCell = "F" & x
            lookupCell = "D" & x
                            
             If Range(lookupCell).Value <> "" Then
                GetValuesFromClosedWorkbook fPath, fName, sName, destCell, lookupCell, lookupRange, lCol, False
            End If
        
        Next x
        
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    
    If Selection.Address = ActiveSheet.Cells.Address Then ActiveSheet.UsedRange
    
    Selection.Formula = Selection.Value
    
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    
        
    End Sub


    The bold/underlined portion is the code that is turning the formulas into values but is forcing the user to select/specify the rows in which to do that. I need it done automatically.


    THANKS in advance for the help!!!!!!!

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Formula Showing, Need the Value Instead

    Sub GetValuesFromClosedWorkbook(fPath As String, fName As String, Shname, OutputRge As String, _
        LookupVal As String, TableArryRge As String, LookupCol As Integer, rangeLkup As Integer)
    
        With ActiveSheet.Range(OutputRge)
            .Formula = "=VLOOKUP(" & LookupVal & ",'" & fPath & "[" & fName & "]" & Shname & _
                        "'!" & TableArryRge & "," & LookupCol & "," & rangeLkup & ")"
            .value = .value
        End With
        
        
    End Sub
    Sub test()
    
    Dim fPath As String
    Dim fName As String
    Dim sName As String
    Dim destCell As String
    Dim lookupCell As String
    Dim lookupRange As String
    Dim lCol As Integer
    Dim beginpos As Long
    Dim x As Long
    Dim RowCount As Long
    
        RowCount = ActiveSheet.Range("D" & Rows.Count).End(xlUp).row
        beginpos = 2
        fPath = "T:\blah\billing\blah\Sblahaasfs\Test\"
        If Right(fPath, 1) <> "\" Then fPath = fPath & "\"
        lookupRange = "A2:I29"
        lCol = 9
        fName = "Master1.xlsx"
        sName = "Master1"
       
    Application.DisplayAlerts = False
       
        For x = beginpos To RowCount
        
            destCell = "F" & x
            lookupCell = "D" & x
                            
             If Range(lookupCell).Value <> "" Then
                GetValuesFromClosedWorkbook fPath, fName, sName, destCell, lookupCell, lookupRange, lCol, False
            End If
        
        Next x
      
        
    End Sub

  3. #3
    Registered User
    Join Date
    10-28-2013
    Location
    Pennylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Formula Showing, Need the Value Instead

    yudlugar,

    From what I gather by your reply, I just need to take that portion out completely? And then the values will post correctly?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Formula Showing, Need the Value Instead

    Sub GetValuesFromClosedWorkbook(fPath As String, fName As String, Shname, OutputRge As String, _
        LookupVal As String, TableArryRge As String, LookupCol As Integer, rangeLkup As Integer)
    
        With ActiveSheet.Range(OutputRge)
            .Formula = "=VLOOKUP(" & LookupVal & ",'" & fPath & "[" & fName & "]" & Shname & _
                        "'!" & TableArryRge & "," & LookupCol & "," & rangeLkup & ")"
            .value = .value      
    end with 
        
    End Sub
    I added that bit

  5. #5
    Registered User
    Join Date
    10-28-2013
    Location
    Pennylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Formula Showing, Need the Value Instead

    yudlugar!!!!! YOU DA MAN!!!!!!!

    THANK YOU SO MUCH! The funny thing is I was playing around with that exact portion you added earlier, I guess I was putting it in the wrong spot.

    Thanks so much! Life saver!

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Formula Showing, Need the Value Instead

    You might get away with:
    Sub GetValuesFromClosedWorkbook(fPath As String, fName As String, Shname, OutputRge As String, _
        LookupVal As String, TableArryRge As String, LookupCol As Integer, rangeLkup As Integer)
    
        With ActiveSheet.Range(OutputRge)
            .value = EVALUATE("=VLOOKUP(" & LookupVal & ",'" & fPath & "[" & fName & "]" & Shname & _
                        "'!" & TableArryRge & "," & LookupCol & "," & rangeLkup & ")")
        end with 
        
    End Sub
    Not sure if that would work though

  7. #7
    Registered User
    Join Date
    10-28-2013
    Location
    Pennylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Formula Showing, Need the Value Instead

    Your first bit worked exactly how I needed it to. Thanks yudlugar!

+ 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. [SOLVED] Multiplication in formula =*-.06 is showing too many numbers in formula bar
    By Lowerysgirl in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-19-2013, 12:23 AM
  2. Formula result showing formula, not answer
    By sjm in forum Excel General
    Replies: 3
    Last Post: 02-26-2007, 06:22 AM
  3. Formula Showing Zero instead of nothing
    By Abode in forum Excel General
    Replies: 3
    Last Post: 05-10-2006, 05:10 PM
  4. [SOLVED] Sum Formula Showing Instead of Value :(
    By Carla in forum Excel General
    Replies: 3
    Last Post: 11-22-2005, 04:10 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