+ Reply to Thread
Results 1 to 2 of 2

object error

  1. #1
    Monique
    Guest

    object error

    I am receiving an object error when I run this procedure. I'm not sure why.
    It does the calculation. I have posted the procedure that calls the function.

    Thanks

    Private Sub DivideCells()

    Dim value As Double

    value = 1000

    DivideRange(Range("C15:V15"), value) = Range("C15:V15").value

    End Sub


    Function DivideRange(myRange As Range, myValue)

    Dim myCell As Range

    For Each myCell In myRange
    myCell.value = myCell / myValue
    Next myCell

    End Function


  2. #2
    MIKE215
    Guest

    RE: object error

    Hi Monique -

    You've probably tried this. Change DivideRange to a PRIVATE SUB accepting
    arguements then call DivideRange in your code. It gets you the same result
    without the error.

    Mike
    Sub DivideCells()
    Dim value As Double

    value = 1000
    Call DivideRange(Range("c15:g15"), value)
    End Sub


    Private Sub DivideRange(myRange As Range, myValue)
    Dim myCell As Range

    For Each myCell In myRange
    myCell.value = myCell / myValue
    Next myCell

    End Sub

    "Monique" wrote:

    > I am receiving an object error when I run this procedure. I'm not sure why.
    > It does the calculation. I have posted the procedure that calls the function.
    >
    > Thanks
    >
    > Private Sub DivideCells()
    >
    > Dim value As Double
    >
    > value = 1000
    >
    > DivideRange(Range("C15:V15"), value) = Range("C15:V15").value
    >
    > End Sub
    >
    >
    > Function DivideRange(myRange As Range, myValue)
    >
    > Dim myCell As Range
    >
    > For Each myCell In myRange
    > myCell.value = myCell / myValue
    > Next myCell
    >
    > End Function
    >


+ 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