ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy macro for a list box (https://www.excelbanter.com/excel-programming/398457-copy-macro-list-box.html)

Eric

Copy macro for a list box
 
I am new to VBA and am trying to work with a Userform
On my user form I have listed all contract #'s and they are not in any
particular order. When I click on my userform I want to copy all the tests
for the contract I highlighted to another sheet (sheet 1). How is this done?

ie:
contract #
123
456
789
456
123

I want every test for contract # 456 copied to sheet 1 starting on cell A2.
Can anyone help me??? Please.

Eric

Tom Ogilvy

Copy macro for a list box
 
Prvate Sub CommandButton1_Click()
for i = 0 to Userform1.Listbox1.listcount - 1
if Userform1.Listbox1.Selected(i) then
' call Ron's macro altered to work with your data
end if
Next
End Sub

Autofilter
http://www.rondebruin.nl/copy5.htm

--
Regards,
Tom Ogilvy

"Eric" wrote:

I am new to VBA and am trying to work with a Userform
On my user form I have listed all contract #'s and they are not in any
particular order. When I click on my userform I want to copy all the tests
for the contract I highlighted to another sheet (sheet 1). How is this done?

ie:
contract #
123
456
789
456
123

I want every test for contract # 456 copied to sheet 1 starting on cell A2.
Can anyone help me??? Please.

Eric


Eric

Copy macro for a list box
 
Tom,

The "Create a new sheet for all unique values" macro works well but I don't
want to have a new sheet for every contract Number as a matter of fact I
don't want the sheet to even change names. I just want to copy all the
identical contract numbers to a separate sheet so that I can graph the
results. Each time I transphere the information I want them to end up back
on the second sheet no matter what the number is. I hope I explained what I
am looking for. If I haven't I will try again. Please be patient with me.
Thank you

Eric

"Tom Ogilvy" wrote:

Prvate Sub CommandButton1_Click()
for i = 0 to Userform1.Listbox1.listcount - 1
if Userform1.Listbox1.Selected(i) then
' call Ron's macro altered to work with your data
end if
Next
End Sub

Autofilter
http://www.rondebruin.nl/copy5.htm

--
Regards,
Tom Ogilvy

"Eric" wrote:

I am new to VBA and am trying to work with a Userform
On my user form I have listed all contract #'s and they are not in any
particular order. When I click on my userform I want to copy all the tests
for the contract I highlighted to another sheet (sheet 1). How is this done?

ie:
contract #
123
456
789
456
123

I want every test for contract # 456 copied to sheet 1 starting on cell A2.
Can anyone help me??? Please.

Eric



All times are GMT +1. The time now is 03:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com