+ Reply to Thread
Results 1 to 3 of 3

Error trying to select a cell

  1. #1
    Registered User
    Join Date
    07-20-2005
    Posts
    13

    Error trying to select a cell

    Hey guys, this should be a simple one but I still havn't gotten it. The code is here:

    Please Login or Register  to view this content.
    Conversion, Flush and Additive are all seperate functions being called to from here. The error is in this line:

    Please Login or Register  to view this content.
    It returns a select range error on this line implying that it is not properly addressed.

    Thanks.

    ~Jason

  2. #2
    Tom Ogilvy
    Guest

    Re: Error trying to select a cell

    If you use the function in a cell like the SUM function as an example, then
    you should not attempt to do any activating or selection.

    If you just call this from VBA, then the sheet calculations must be the
    active sheet to successfully execute that command. Otherwise it should be

    ThisWorkbook.Activate
    Worksheets("Calculations").Activate
    For i = 20 To 29

    For j = 7 To 15

    ThisWorkbook.Worksheets("Calculations").Cells(i, j).Select
    component = ThisWorkbook.Worksheets("Calculations").Cells(ActiveCell.row,
    6).Value

    Select Case component
    Case 1
    answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
    Case 2
    answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
    Case Else
    answers(i, j) = conversion(i, j)
    End Select
    Next j

    Next i

    --
    Regards,
    Tom Ogilvy


    "jclark419" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hey guys, this should be a simple one but I still havn't gotten it. The
    > code is here:
    >
    >
    > Code:
    > --------------------
    >
    > Public Function results() As Double
    >
    > Dim answers(9, 9) As Double
    > Dim i, j, component As Integer
    >
    >
    > For i = 20 To 29
    >
    > For j = 7 To 15
    >
    > ThisWorkbook.Worksheets("Calculations").Cells(i, j).Activate
    > component =

    ThisWorkbook.Worksheets("Calculations").Cells(ActiveCell.row, 6).Value
    >
    > Select Case component
    > Case 1
    > answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
    > Case 2
    > answers(i, j) = conversion(i, j) + flush(i, j) + additive(i, j)
    > Case Else
    > answers(i, j) = conversion(i, j)
    > End Select
    > Next j
    >
    > Next i
    >
    > End Function
    >
    > --------------------
    >
    >
    > Conversion, Flush and Additive are all seperate functions being called
    > to from here. The error is in this line:
    >
    >
    > Code:
    > --------------------
    >
    > ThisWorkbook.Worksheets("Calculations").Cells(i, j).Select
    >
    > --------------------
    >
    >
    > It returns a select range error on this line implying that it is not
    > properly addressed.
    >
    > Thanks.
    >
    > ~Jason
    >
    >
    > --
    > jclark419
    > ------------------------------------------------------------------------
    > jclark419's Profile:

    http://www.excelforum.com/member.php...o&userid=25430
    > View this thread: http://www.excelforum.com/showthread...hreadid=392200
    >




  3. #3
    Registered User
    Join Date
    07-20-2005
    Posts
    13
    That took care of it.
    Thanks for your help.

    ~Jason

+ 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