+ Reply to Thread
Results 1 to 6 of 6

Input box range - output range

  1. #1
    al007
    Guest

    Input box range - output range

    Sub UniqueFindColumn()
    Dim AnArray() As String, i As Long
    Dim Selec As Range
    Dim Desti As Range
    Set Selec = Application.InputBox( _
    Prompt:="Select cell for Actual data.", Type:=8)

    Set Desti = Application.InputBox( _
    Prompt:="Select cell for Actual data.", Type:=8)
    AnArray = GetUniqueEntries(Selec)
    If Len(AnArray(0)) > 0 Then
    For i = 0 To UBound(AnArray)
    Range(Desti).Offset(i, 0) = AnArray(i)
    Next
    End If
    End Sub

    What wrong in the above macro with respect to my output i.e Desti
    range.
    Thxs

    Actual I tried to amend the macro below:
    Sub UniqueFind()
    Dim AnArray() As String, i As Long
    AnArray = GetUniqueEntries(Range("A1:D12"))
    If Len(AnArray(0)) > 0 Then
    For i = 0 To UBound(AnArray)
    Range("F1").Offset(i, 0) = AnArray(i)
    Next
    End If
    End Sub


  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello al007,

    The range object variables must be set to an existing reference. I made the changes to your code for you. The InputBox is merely supplying a string address that describes the range and is not itself a range. You can not reference cells that are not on the active sheet with this Sub.

    Sub UniqueFindColumn()
    Dim AnArray() As String, i As Long
    Dim Selec As Range
    Dim Desti As Range
    Dim Rng
    Rng = InputBox( "Select cell for Actual data.")
    Set Selec = Range(Rng)

    Rng = InputBox( "Select cell for Actual data.")
    Set Desti = Range(Rng)
    AnArray = GetUniqueEntries(Selec)
    If Len(AnArray(0)) > 0 Then
    For i = 0 To UBound(AnArray)
    Range(Desti).Offset(i, 0) = AnArray(i)
    Next
    End If
    End Sub
    Last edited by Leith Ross; 11-21-2005 at 06:48 AM.

  3. #3
    al007
    Guest

    Re: Input box range - output range

    Ross,
    The code is stopping at

    Set Selec = Range(Rng)

    PLs help


  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello al007,

    What did you type into the input box?

    Thanks,
    Leith Ross

  5. #5
    al007
    Guest

    Re: Input box range - output range

    My selected range e.g A1:D12
    My desti range e.g F1


    Guess code need to amended

    thxs


  6. #6
    Dave Peterson
    Guest

    Re: Input box range - output range

    Desti is already a range.

    I think you want:
    Desti.Offset(i, 0) = AnArray(i)

    instead of:
    Range(Desti).Offset(i, 0) = AnArray(i)


    al007 wrote:
    >
    > Sub UniqueFindColumn()
    > Dim AnArray() As String, i As Long
    > Dim Selec As Range
    > Dim Desti As Range
    > Set Selec = Application.InputBox( _
    > Prompt:="Select cell for Actual data.", Type:=8)
    >
    > Set Desti = Application.InputBox( _
    > Prompt:="Select cell for Actual data.", Type:=8)
    > AnArray = GetUniqueEntries(Selec)
    > If Len(AnArray(0)) > 0 Then
    > For i = 0 To UBound(AnArray)
    > Range(Desti).Offset(i, 0) = AnArray(i)
    > Next
    > End If
    > End Sub
    >
    > What wrong in the above macro with respect to my output i.e Desti
    > range.
    > Thxs
    >
    > Actual I tried to amend the macro below:
    > Sub UniqueFind()
    > Dim AnArray() As String, i As Long
    > AnArray = GetUniqueEntries(Range("A1:D12"))
    > If Len(AnArray(0)) > 0 Then
    > For i = 0 To UBound(AnArray)
    > Range("F1").Offset(i, 0) = AnArray(i)
    > Next
    > End If
    > End Sub


    --

    Dave Peterson

+ 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