Listbox data to be moved in worksheet

xsmurf

Board Regular
Joined
Feb 24, 2007
Messages
55
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a question that involves moving and deleting data from a listbox.

I use below code to update data in a userform listbox, this works perfect.
I want to add an extra function that when I mark the data as "finished" that the selected row will be moved to a new location.
When I open the userform the listbox is populated with a named range "Action24hrOpen", all the rows have an ID number. (column A)
The data is in column b/c/d/e/f.
When I mark the data as finished column E will get a "Yes" value, otherwise it is "No"
when it is marked "Yes", I would like that data to be moved to columns i/j/k/l/m on the same sheet.
The range for that location is called "Action24hrDone"

So when marked a row has "Yes" in column "E", that row needs to be moved to the new location

Could some one please help me make this possible ?

Thanks in advance.

VBA Code:
Private Sub cmb_Update24HrAction_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("24 Hr_Long Term_DMS3")
Dim Selected_row_email As Long
Selected_row_email = Application.WorksheetFunction.Match(CLng(Me.txt_24hrAction_ID.value), sh.Range("A:A"), 0)
Me.cb_24hrActionFinished.Visible = False
If Me.txtNew24hrAction.value = "" Then
MsgBox "Problem area cannot be empty"
Exit Sub
End If
'-----------------------------------------------------------
sh.Range("B" & Selected_row_email).value = Me.txtNew24hrAction.value
sh.Range("C" & Selected_row_email).value = Format(Me.txtNew24hrName.value, "mmm dd, yyyy")
sh.Range("D" & Selected_row_email).value = Me.txtNew24hrDate.value
If cb_24hrActionFinished = True Then
sh.Range("E" & Selected_row_email).value = "Yes"
sh.Range("F" & Selected_row_email).value = Format(Now, "mmm dd, yyyy")
Else
sh.Range("E" & Selected_row_email).value = "No"
sh.Range("F" & Selected_row_email).value = Empty

End If
'-----------------------------------------------------------
Me.txtNew24hrAction.value = ""
Me.txtNew24hrName.value = ""
Me.txtNew24hrDate.value = ""
Me.txt_24hrAction_ID = ""
Me.Label9.Caption = "Enter a NEW 24 Hr Action"
cmb_Add24HrAction.Visible = True
cmb_Update24HrAction.Visible = False
Me.cb_24hrActionFinished.Visible = False
'-----------------------------------------------------------
Call Refresh_24hrAction
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top