PDA

View Full Version : Populate spreadsheet cells based on multi select listbox and combo boxes



Loss1003
09-09-2016, 11:34 AM
Please assist with some vba coding on how to populate spreadsheet cells based on multi select listbox and two (2) combo boxes.

For example,

If the user selects “C” in the Set Column combo box & then sets the percentage to 10 in the Set Percentage combo box & then selects the following numbers 1,3,&5 within the Set Numbers Listbox. The following below result should be generated after the code is run.

If zero is already present in the cell, the percentage selected by the user should override and be listed in the appropriate rows wherein any set numbers that were selected.

Any and all help is appreciated.


Sec #

Set#

A

B

C

D

E

F



1

1.01

0

0

10

0

0

0



1

1.02

0

0

10

0

0

0



1

1.03

0

0

10

0

0

0



1

1.04

0

0

10

0

0

0



1

1.05

0

0

10

0

0

0



1

1.06

0

0

10

0

0

0



1

1.07

0

0

10

0

0

0



1

1.08

0

0

10

0

0

0



1

1.09

0

0

10

0

0

0



1

1.1

0

0

10

0

0

0



2

2.01

0

0

0

0

0

0



2

2.02

0

0

0

0

0

0



2

2.03

0

0

0

0

0

0



2

2.04

0

0

0

0

0

0



2

2.05

0

0

0

0

0

0



2

2.06

0

0

0

0

0

0



2

2.07

0

0

0

0

0

0



2

2.08

0

0

0

0

0

0



2

2.09

0

0

0

0

0

0



2

2.1

0

0

0

0

0

0



3

3.01

0

0

10

0

0

0



3

3.02

0

0

10

0

0

0



3

3.03

0

0

10

0

0

0



3

3.04

0

0

10

0

0

0



3

3.05

0

0

10

0

0

0



3

3.06

0

0

10

0

0

0



3

3.07

0

0

10

0

0

0



3

3.08

0

0

10

0

0

0



3

3.09

0

0

10

0

0

0



3

3.1

0

0

10

0

0

0



4

4.01

0

0

0

0

0

0



4

4.02

0

0

0

0

0

0



4

4.03

0

0

0

0

0

0



4

4.04

0

0

0

0

0

0



4

4.05

0

0

0

0

0

0



4

4.06

0

0

0

0

0

0



4

4.07

0

0

0

0

0

0



4

4.08

0

0

0

0

0

0



4

4.09

0

0

0

0

0

0



4

4.1

0

0

0

0

0

0



5

5.01

0

0

10

0

0

0



5

5.02

0

0

10

0

0

0



5

5.03

0

0

10

0

0

0



5

5.04

0

0

10

0

0

0



5

5.05

0

0

10

0

0

0



5

5.06

0

0

10

0

0

0



5

5.07

0

0

10

0

0

0



5

5.08

0

0

10

0

0

0



5

5.09

0

0

10

0

0

0



5

5.1

0

0

10

0

0

0

SamT
09-09-2016, 07:02 PM
UserForm Code

Private Sub CommandButton1_Click()
FillTable
'Unload Me
End Sub


Private Sub FillTable()
Const SkipRows As Long = 1 'Number of header rows. Table starts after this row #

Dim i As Long

With Me.Rounds1
For i = 0 To .ListCount - 1
If .Selected(i) Then Sheets("Table").Cells((i * 10) + SkipRows, ColNum(Me.Pos1)).Resize(10).Value = Me.Per1
Next i
End With

End Sub


Private Function ColNum(ColAlpha As String) As Long
Select Case ColAlpha
Case "A": ColNum = 3
Case "B": ColNum = 4
Case "C": ColNum = 5
Case "D": ColNum = 6
Case "E": ColNum = 7
Case "F": ColNum = 8
End Select
End Function

You must change Rounds1 MultiSelect Property to 1-fmMultiSelectMulti