Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi good afternoon, hope you can help me please. I am trying to get ListBox2 to update when data is entered into a sheet called 'Raised' which is 'sh3 and a sheet called 'Outages' which is sh1, the first part of the code works for 'sh3' but the other part i added for 'sh1' doesn't work, i hope you can help me please?
VBA Code:
Private Sub CommandButton8_Click()
Dim i As Long, itm As Long
Application.ScreenUpdating = False
For i = 0 To Me.ListBox2.ListCount - 1
If Me.ListBox2.Selected(i) Then
itm = i + 2
Exit For
End If
Next i
sh3.Rows(itm).Copy
sh2.Range("A" & lrB + 1).PasteSpecial xlValues
sh3.Rows(itm).ClearContents
Application.CutCopyMode = False
sh3.Range("A1:J" & sh3.Range("A" & Rows.Count).End(xlUp).Row).Sort Key1:=sh3.Range("A1"), Order1:=xlAscending, Header:=xlYes
End If
Next i
sh1.Rows(itm).Copy
sh2.Range("A" & lrB + 1).PasteSpecial xlValues
sh1.Rows(itm).ClearContents
Application.CutCopyMode = False
sh1.Range("A1:J" & sh1.Range("A" & Rows.Count).End(xlUp).Row).Sort Key1:=sh1.Range("A1"), Order1:=xlAscending, Header:=xlYes
Application.ScreenUpdating = True
ws1Rng
ws2Rng
ws3Rng
End Sub