Please help. Need vba to copy and paste based on combos result. Thanks

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,

In book1 of Sheet1
I have from Combobox1 validation(ActiveX)
And the list has names,like Kath, James, Aaron etc.
whenever I select any names I want the macro to go and select book2, copy the range("A1:B10") for kath and come back to book1 and paste
in range E1.If James is selected copy the range("G1:J10") for kath and come back to book1 and paste
in range E1 etc..
Pls give me the idea of the vba code and so that i can work out the rest.

Thanks for helping.
Pedie
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello

In book2 sheet1, name the ranges for each individual, IE name A1:B10 Kath, G1:J10 name James, ECT.
Then try.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> ComboBox1_Change()<br>  Range("E1").CurrentRegion.ClearContents<br>    Workbooks("Book2").Sheets("sheet1").Range(ComboBox1.Value).Copy Range("E1")<br>  Range("E1").CurrentRegion.Columns.AutoFit<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Meldoc, thanks for replying has blackout last night so could not return to see my answer...

k, actually i was trying to pull the information from read only...so I will not be able to name range...

Please when you come around...do me a modification. And the file is not in my desk top but i have the path to shared network drive. My current code is below, please add more if and condition to it...and file path...


Thanks again
Pedie;)

I was trying it withing one sheet as i dont know how to connect to other workbook...:biggrin:

Code:
Private Sub ComboBox1_Change()
  If ComboBox1.Value = "James" Then
   Sheets("Sheet1").Range("B2:D10").Copy
   Sheets("Main").Select
   Range("J3").Select
   ActiveSheet.Paste
  
   Else
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,749
Messages
6,167,967
Members
452,158
Latest member
MattyM

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