User selecting range from userform via dropdown menue

M

mslabbe

Hi All!

I've searched for this for a while, and have had no luck! Also, I will doe the best to
explain exactly what I'm trying to do...but it might be tough...here goes!

I'm using VB within Excel. From a userform, I'd like to use a drop down menue (which I
already know how to do). The list would be of ranges (already set-up via insert->name->
define). So, when the user selects the item, they would have selected a range in the
background. Then, I'd like to copy the now selected range and paste it to a new area.

This would be repeated everytime the user starts over, however, the ranges will be different
depending on which range the user selects.

Is it too confusing or impossible? I have tried recording a macro and using the
"application.goto" option, however, all that it does is a specific range name and I could
not have the user select it...

Thanks in advance
Matt
 
T

Tom Ogilvy

Private Sub Combobox1_Click()
Dim rng as Range
On error resume Next
set rng = Range(combobox1.Value)
On error goto 0
if not rng is nothing then
rng.copy Destination:=Range("AA1")
end if
End sub
 
B

Bob Phillips

Matt,

Is it not just

With Activesheet
.Range(Me.Combobox1.Value).Copy Destination:=.Range("copyArea")
End With

from with the form

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top