+ Reply to Thread
Results 1 to 3 of 3

Referencing a Cell in VBA

  1. #1
    Registered User
    Join Date
    02-05-2006
    Posts
    40

    Question Referencing a Cell in VBA

    Hi All,

    Below is a few lines of VBA from my spread sheet:

    Function fnSMYS(strSteelGrade)
    If Cells(4, 3).Value = "A25" Then
    fnSMYS = 172.4
    ElseIf (Cells(4, 3).Value = "A") Then
    fnSMYS = 206.9
    .....etc

    As you can see it is a function and it is checking the value of cell 4,3 (or 4C) and then it assigns fnSMYS a value depending on what is in 4,3. In my spread sheet I have called cell 4,3 "Grade". How can I replace the line Cells "(4,3).Value" in VBA with a reference to the name "Grade"?

    Best Regards,

    Aaron

  2. #2
    Ardus Petus
    Guest

    Re: Referencing a Cell in VBA

    If Range("Grade").Value = "A25" Then


    HTH
    --
    AP

    "Aaron1978" <[email protected]> a écrit
    dans le message de news:
    [email protected]...
    >
    > Hi All,
    >
    > Below is a few lines of VBA from my spread sheet:
    >
    > Function fnSMYS(strSteelGrade)
    > If Cells(4, 3).Value = "A25" Then
    > fnSMYS = 172.4
    > ElseIf (Cells(4, 3).Value = "A") Then
    > fnSMYS = 206.9
    > ....etc
    >
    > As you can see it is a function and it is checking the value of cell
    > 4,3 (or 4C) and then it assigns fnSMYS a value depending on what is in
    > 4,3. In my spread sheet I have called cell 4,3 "Grade". How can I
    > replace the line Cells "(4,3).Value" in VBA with a reference to the
    > name "Grade"?
    >
    > Best Regards,
    >
    > Aaron
    >
    >
    > --
    > Aaron1978
    > ------------------------------------------------------------------------
    > Aaron1978's Profile:
    > http://www.excelforum.com/member.php...o&userid=31201
    > View this thread: http://www.excelforum.com/showthread...hreadid=546243
    >




  3. #3
    Registered User
    Join Date
    02-05-2006
    Posts
    40
    Excellent. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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