Results 1 to 5 of 5

Thread: Excel VBA: UDF Not Working; Please Explain?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Posts
    74

    Question Excel VBA: UDF Not Working; Please Explain?

    I'm trying to learn how to perform User Defined Functions in Excel, and I thought this code (below) would be a winner on first pass; but it was not.

    Code:
    Public Function change2F() As Variant
    Dim result As Variant
    Dim sht As Worksheet
        change2F = (sht.Range("a:a") - 32) * 5 / 9
        change2F = result
            
    End Function
    Basically, I have in column A, a set of numbers from 0 to 100 (by 5's; representing Fahrenheit values) and I'm trying to get the Celsius equivalent to those numbers.
    Name:  Capture12.PNG
Views: 471
Size:  7.8 KB

    I have tried to toy with the code and keep getting "#VALUE!" errors

    Can someone explain why this code isn't working? I've tried several different data types and combinations to no avail: Integer, Variance, Long ... nothing seems to be working.

    What's going wrong with this code?
    Attached Images Attached Images  

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width