Results 1 to 3 of 3

Set Ranges Throwing Unknown Error

Threaded View

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Set Ranges Throwing Unknown Error

    Hi all,

    The following code is a part of a function that I am working on.
    Private Function FindIntersect(ByVal DtRng As Range, FndSel As Range, Region As String, IndBool As Boolean)
        Dim cl As Range, Dts As Range
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '''ValArrayF() is for values that are not user indexed'''
        '''ValArrayT() is for values that are user indexed    '''
        Dim ValArrayF() As Double, ValArrayT() As Double
        Dim DisplayDtRng As Range, DisplayFndSel As Range
        Dim AryCnt As Long, AryCntr As Long
        Dim DtCnt As Long, rCnt As Long, cCnt As Long
        Dim Ws1 As Worksheet, Ws2 As Worksheet, Ws3 As Worksheet
        Set Ws1 = Worksheets("Qrtr")
        Set Ws2 = Worksheets("Sheet2")
        Set Ws3 = Worksheets("Sheet3")
        AryCnt = DtRng.Cells.Count
        AryCntr = 0
        If IndBool = False Then
            ReDim ValArrayF(AryCnt)
        Else:
            ReDim ValArrayT(AryCnt + 1)
        End If
        Set Dts = Ws2.Range("B19").Resize(, AryCnt)
        Debug.Print Dts.Address        '''Debugs as $B$19:$G$19
        Debug.Print DtRng.Address    '''Debugs as $C$7:$C$12
        Dts.Cells.Value = DtRng.Cells.Value
        With Dts.Cells
             .Interior.ColorIndex = xlNone
             .BorderAround xlSolid, xlMedium
             .Font.Bold = True
             .Font.Size = 12
        End With
        '....More Code....'
    End Function
    This code worked up until I added
    With Dts.Cells
             .Interior.ColorIndex = xlNone
             .BorderAround xlSolid, xlMedium
             .Font.Bold = True
             .Font.Size = 12
        End With
    and now for some reason stops at
    Dts.Cells.Value = DtRng.Cells.Value
    I can't for the life of me see why! Also, the error prompt is a none descriptive message with a big X on the left side and the number 400 on the right. If anyone can see why I would appreciate your comments. Until then, I guess debugging each line of code for my whole project may be needed.

    Thanks
    Last edited by Mordred; 07-28-2011 at 08:41 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

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