I have a VBA routine that lets user select a column
I then want to use the value of OUTPUT which is something like $A:A into another piece of code which splits the excel worksheet, so the following piece of code in RED
should be able to accept the value selected, if for example user selects column A, then OUTPUT would have $A:$A as it's value, I need to find a way to get that value into the code in red below, the first piece in red gets the whole value of OUTPUT while the second piece in red just gets the column name and the number 1, example A1.
I tried and tried and cannot get this to work, so any suggestions will be highly appreciated.
Michael
Code:
Sub getcolumns()
Dim userRange As RANGE, output As String
'get a range from the user via an input box
On Error Resume Next
Set userRange = Application.InputBox( _
prompt:="Select cells on a single column for processing", _
Type:=8, Default:=Selection.Address)
On Error GoTo 0
'if no range selected, stop
If userRange Is Nothing Then Exit Sub
'if cells on more than one row selected, display message and stop
If userRange.Columns.Count > 1 Then
MsgBox "Select just cells on a single column. " & _
"No action taken"
'stop the macros
End
Else
output = userRange.Columns.Address
MsgBox "This is what you selected. " & output & ""
End If
End Sub
I then want to use the value of OUTPUT which is something like $A:A into another piece of code which splits the excel worksheet, so the following piece of code in RED
should be able to accept the value selected, if for example user selects column A, then OUTPUT would have $A:$A as it's value, I need to find a way to get that value into the code in red below, the first piece in red gets the whole value of OUTPUT while the second piece in red just gets the column name and the number 1, example A1.
I tried and tried and cannot get this to work, so any suggestions will be highly appreciated.
Code:
[COLOR=red]
ws1.Columns(output).Copy _[/color]
Destination:=RANGE("IU1")
ws1.Columns("IU:IU").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=RANGE("IV1"), Unique:=True
r = Cells(Rows.Count, "IV").End(xlUp).Row
[COLOR=red]RANGE("IU1").Value = RANGE("a1").Value
[/color]
Michael