ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input box range - output range (https://www.excelbanter.com/excel-programming/346131-input-box-range-output-range.html)

al007

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


Leith Ross[_293_]

Input box range - output range
 

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 = Application.InputBox( _
Prompt:="Select cell for Actual data.", Type:=8)
Set Selec = Range(Rng)

Rng = Application.InputBox( _
Prompt:="Select cell for Actual data.", Type:=8)
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


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=486773


al007

Input box range - output range
 
Ross,
The code is stopping at

Set Selec = Range(Rng)

PLs help


Leith Ross[_295_]

Input box range - output range
 

Hello al007,

What did you type into the input box?

Thanks,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=486773


al007

Input box range - output range
 
My selected range e.g A1:D12
My desti range e.g F1


Guess code need to amended

thxs


Dave Peterson

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


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com