moviewoman
New Member
- Joined
- Nov 17, 2015
- Messages
- 3
I have a UserForm that takes data from a Multicolumn Listbox and inputs the selected data to an Excel sheet. I have the sheet and row to input the data correct but can not get the column to print correctly. I have changed column values including: 0, 1, 2, 3. Using 0 it returns in column A, using 1 it returns in column E, and using 2 it returns in column F. I just can't figure out why it is doing this. Here is the code I am using:
Private Sub UpdatePart_Click()
elr = Me.ExistingList.Column(5) - 1
With Worksheets(Me.ExistingList.Column(0)).Select
If Me.ExistingList.Value = "" Then
MsgBox "Choose Shop Supply to Change", vbExclamation, "Change Part Error"
Me.ExistingList.SetFocus
Exit Sub
End If
If Me.NewOnHand.Value = "" And Me.NewLocation.Value = "" And Me.NewLocation2.Value = "" Then
MsgBox "Enter a Value to Change", vbExclamation, "Change Part Error"
Me.NewOnHand.SetFocus
Exit Sub
End If
If Me.NewOnHand.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, 1).Value = Me.NewOnHand.Value
End With
Exit Sub
End If
If Me.NewLocation.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, 2).Value = Me.NewLocation.Value
End With
Exit Sub
End If
LastUsed = Range(Me.ExistingList.Column(5) & ColumnCount).End(xlToLeft).Column
Do Until Range(Me.ExistingList.Column(5) & LastUsed).Value <> ""
LastUsed = LastUsed - 1
Loop
Range(Me.ExistingList.Column(5) & LastUsed).Select
If Me.NewLocation2.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, LastUsed).Value = Me.NewLocation2.Value
End With
Exit Sub
End If
End With
End Sub
Private Sub UpdatePart_Click()
elr = Me.ExistingList.Column(5) - 1
With Worksheets(Me.ExistingList.Column(0)).Select
If Me.ExistingList.Value = "" Then
MsgBox "Choose Shop Supply to Change", vbExclamation, "Change Part Error"
Me.ExistingList.SetFocus
Exit Sub
End If
If Me.NewOnHand.Value = "" And Me.NewLocation.Value = "" And Me.NewLocation2.Value = "" Then
MsgBox "Enter a Value to Change", vbExclamation, "Change Part Error"
Me.NewOnHand.SetFocus
Exit Sub
End If
If Me.NewOnHand.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, 1).Value = Me.NewOnHand.Value
End With
Exit Sub
End If
If Me.NewLocation.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, 2).Value = Me.NewLocation.Value
End With
Exit Sub
End If
LastUsed = Range(Me.ExistingList.Column(5) & ColumnCount).End(xlToLeft).Column
Do Until Range(Me.ExistingList.Column(5) & LastUsed).Value <> ""
LastUsed = LastUsed - 1
Loop
Range(Me.ExistingList.Column(5) & LastUsed).Select
If Me.NewLocation2.Value > "" Then
With Worksheets(Me.ExistingList.Column(0)).Range("A1")
.Offset(elr, LastUsed).Value = Me.NewLocation2.Value
End With
Exit Sub
End If
End With
End Sub