Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Excel Formula to Immediate Window and/or Work with the actual formula 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I must be going batty, because I could swear I've done this before.

For some Excel changes, I want to use a value in one formula to create something in a different cell via VBA code. But for initial testing, I just want to be able to print the actual formula text to the immediate window.

So this is what I've got so far, and it's giving me the values instead of formula text:
Code:
Sub GetFirstLastNames()
    Dim wb As Workbook
    Dim wsMain As Worksheet
    Dim ws As Worksheet 'for looping through sheets
    Dim x As Integer
    
    Set wb = ActiveWorkbook
    Set wsMain = wb.Worksheets("Complete List")
    
    For x = 3 To wsMain.Range("F3").End(xlDown).Row
         [highlight #FCE94F]Debug.Print wsMain.Cells(x, 6).[b]Formula[/b] & "   " & InStr(1, wsMain.Cells(x, 6).[b]Formula[/b], "!")[/highlight]
    Next x

    Set ws = Nothing
    Set wb = Nothing
End Sub

Can anyone tell me what I'm forgetting???


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Hi,

Are you sure that F3 and following contain formulas?

Your code DOES print formulas if the cell contains such.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Oh my... oh my.... and.... oh my...

Yep, It's time for me to go back to bed. Formulas were in column G.

Thanks for rescuing my sanity!

[blush] [banghead]

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top