Thread: combobox cases
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Hannu Rantala Hannu Rantala is offline
external usenet poster
 
Posts: 8
Default combobox cases

Thank you Bob. The program works excellent!


"Bob Phillips" wrote in message ...
Hi Hannu,

With Worksheets("Sheet2")
If Combobox1.ListIndex = 0 Then
.Range("B45:B52 ").Copy Destination:=.Range("B58")
ElseIf Combobox1.ListIndex = 1 Then
.Range("C45:C52 ").Copy Destination:=.Range("B58")
ElseIf Combobox1.ListIndex = 2 Then
.Range("D45:D52 ").Copy Destination:=.Range("B58")
End If
End With

--

HTH

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

"Hannu Rantala" wrote in message
om...
Hello!

I am using excel and combobox to give alternatives for user.
How to programme following command in VBA:

If comboboxselection = 1 Then
Copy from 'sheet2'!B45:B52 & paste to 'sheet2'!B58:B65

If comboboxselection = 2 Then
Copy from 'sheet2'!C45:B52 & paste to 'sheet2'!B58:B65

If comboboxselection = 3 Then
Copy from 'sheet'!D45:D52 & paste to 'sheet2'!B52:B65
.
.
.
repeated sufficient times...

Hannu Rantala