Excel Offset Printing Incorrectly

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
 

Forum statistics

Threads
1,081,518
Messages
5,359,237
Members
400,523
Latest member
ExcelNewbie98

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top