Union and Arguments

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi.

I have a spreadsheet the I wish to select multiple columns that are not continuous.

The problem is, the columns to select may differ therefore, I do not know ahead of time how many arguments in a union that I need.

Is there a method to dynamically define the number of union arguments?

Thanks,
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I'm not really sure what the situation is but you can use Union in a loop to keep increasing the range. I don't really see how you could need Union without knowing what to Union though.
 
Upvote 0
perhaps this would be of use
Code:
Dim uiRange As Range
Dim strPrompt

strPrompt = "Select the range you want with the mouse."
strPrompt = strPrompt & vbCr & vbCr & "Press Ctrl or use commas to select a discontinous range."

On Error Resume Next
Set uiRange = Application.InputBox(strPrompt, Type:=8)
On Error GoTo 0

If uiRange Is Nothing Then Exit Sub: Rem canceled
Set uiRange = uiRange.EntireColumn

MsgBox uiRange.Address
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top