Alexon2008
01-13-2008, 07:40 AM
I have four listbox and when user select items in listbox then macro copy some range in sheet vj and paste them on Sheet1.
But I have to problems with this macro:
1. I want to copy range instead of row
2. How to change macro if I have two or more listbox.
Private Sub CommandButton1_Click()
Dim mpRow As Long
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Select Case .List(i)
Case "Delta": mpRow = 4
Case "Alfa": mpRow = 8
Case "Eta": mpRow = 12
Case "Gamma": mpRow = 16
Case "Omega": mpRow = 20
End Select
Worksheets("vj").Rows(mpRow).Copy
With Worksheets("Sheet1")
With .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteComments
End With
End With
End If
Next i
End With
End Sub
But I have to problems with this macro:
1. I want to copy range instead of row
2. How to change macro if I have two or more listbox.
Private Sub CommandButton1_Click()
Dim mpRow As Long
Dim i As Long
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Select Case .List(i)
Case "Delta": mpRow = 4
Case "Alfa": mpRow = 8
Case "Eta": mpRow = 12
Case "Gamma": mpRow = 16
Case "Omega": mpRow = 20
End Select
Worksheets("vj").Rows(mpRow).Copy
With Worksheets("Sheet1")
With .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteComments
End With
End With
End If
Next i
End With
End Sub