Hello,
I have a code that I have been using for some time now. I have to make some changes which requires adding another column to the template but I am having trouble getting the data to transfer to the correct cells.
The code I have is as following:
Private Sub cmdAddConstructionRetail_Click()
Dim addme As Range
Dim X As Integer
Set addme = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
For X = 0 To Me.lstConstructionRetail.ListCount - 1
If Me.lstConstructionRetail.Selected(X) Then
addme = Me.lstConstructionRetail.List(X)
addme.Offset(0, 1) = Me.lstConstructionRetail.List(X, 1)
addme.Offset(0, 2) = Me.lstConstructionRetail.List(X, 2)
addme.Offset(0, 2) = Me.lstConstructionRetail.List(X, 3)
Set addme = addme.Offset(1, 0)
End If
Next X
For X = 0 To Me.lstConstructionRetail.ListCount - 1
If Me.lstConstructionRetail.Selected(X) Then Me.lstConstructionRetail.Selected(X) = False
Next X
End Sub
Display More
I have populated the list box with a dynamic name range list which is 4 columns wide but only 3 of those are needed on this particular template. One column is for information purpose only and is not needed on the template.
If I use this code on a test sheet without merged cells it works just like I need it to. But my template has merged cells where the second column of the name range is going. It places the first item from the list in the second column on the template, second item in the third (Merged) column and fails to place the last item on the list in the fourth column.
I have attached a screenshot of the template, Hope that helps.
Thank you in advance for your help.