Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
The code below is launched by a click of a shape on my worksheet.
There are no errors, and it for the most part is performing the core needs. The one thing it isn't doing, is formatting my shape properly.
The very first process in this code is to change the status and formatting of different shapes. One is the shape that the user clicked to enable the code. It's supposed to turn the border of the clicked shape green.
It does this, but only after all the code is executed. What I was aiming for was for the shape to format, then to run the code, not the other way around. The green highlighting of the shape is a visual indication to the user what shape was pressed and what code is running. Any idea how I can achieve the results I am looking for?
There are no errors, and it for the most part is performing the core needs. The one thing it isn't doing, is formatting my shape properly.
The very first process in this code is to change the status and formatting of different shapes. One is the shape that the user clicked to enable the code. It's supposed to turn the border of the clicked shape green.
It does this, but only after all the code is executed. What I was aiming for was for the shape to format, then to run the code, not the other way around. The green highlighting of the shape is a visual indication to the user what shape was pressed and what code is running. Any idea how I can achieve the results I am looking for?
Rich (BB code):
Sub emp_delete()
'Stop
Dim rbupath As String, mbupath As String
Dim ws_postm As Worksheet
Dim ws_postr As Worksheet
'ScreenUpdating = True
MsgBox "Employee Delete"
mbevents = False
With ws_staffrec
With .Shapes("emp_delete_b").Line
.ForeColor.RGB = RGB(131, 249, 43) 'green
End With
With .Shapes("emp_edit_b").Line
.ForeColor.RGB = RGB(56, 93, 138)
.Visible = False
End With
.Shapes("emp_edit_g").Visible = True
With .Shapes("emp_submit_b").Line
.ForeColor.RGB = RGB(56, 93, 138)
.Visible = False
End With
.Shapes("emp_submit_g").Visible = True
End With
ui1 = MsgBox("By continuing this action:" & Chr(13) & " - this employee will be removed from the roster; " & Chr(13) & _
" - all shifts assigned to this employee will be vacated" & Chr(13) & Chr(13) & "Are you certain you wish to proceed?", vbCritical + vbYesNo, "CRITICAL DATA LOSS")
If ui1 = vbNo Then
mbevents = True
Exit Sub
End If
'Stop
'backup
rbupath = "D:\WSOP 2020\Backup\Roster\"
mbupath = "D:\WSOP 2020\Backup\Master\"
Application.ScreenUpdating = False
Set newbook = Workbooks.Add
Workbooks("SOP Schedule.xlsm").Worksheets("Master").Copy Before:=newbook.Sheets(1)
fname = Format(Now, "yy-mm-dd.hhmm") & "_BUmaster.xlsx"
Application.DisplayAlerts = False
newbook.SaveAs Filename:=mbupath & fname
newbook.Close
MsgBox "MASTER schedule backed up.No changes have been made.", , fname
Set newbook = Workbooks.Add
Workbooks("SOP Schedule.xlsm").Worksheets("ROSTER").Copy Before:=newbook.Sheets(1)
fname = Format(Now, "yy-mm-dd.hhmm") & "_BUroster.xlsx"
newbook.SaveAs Filename:=rbupath & fname
newbook.Close
MsgBox "ROSTER schedule backed up. No changes have been made.", , fname
Workbooks.Open Filename:="D:\WSOP 2020\Backup\EmployeeArchive\PostSchedule.xlsx"
Workbooks("PostSchedule.xlsx").Windows(1).Visible = False
Workbooks.Open Filename:="D:\WSOP 2020\Backup\EmployeeArchive\PostRoster.xlsx"
Workbooks("PostRoster.xlsx").Windows(1).Visible = False
Set ws_postm = Workbooks("PostSchedule.xlsx").Worksheets("PostSchedule")
Set ws_postr = Workbooks("PostRoster.xlsx").Worksheets("PostRoster")
'transfer roster entry
en = ws_staffrec.Range("B6").Value
srow = Application.WorksheetFunction.Match(en, ws_roster.Columns(1), 0)
drow = ws_postr.Cells(ws_postr.Rows.Count, "A").End(xlUp).Row + 1
ws_roster.Rows(srow).Copy
Workbooks("PostRoster.xlsx").Windows(1).Visible = True
ws_roster.Rows(srow).Copy ws_postr.Rows(drow)
Workbooks("PostRoster.xlsx").Close SaveChanges:=True
'transfer master schedule
col_ref = ws_roster.Cells(srow, 9)
Set s_rng = ws_master.Columns(col_ref).Resize(, 5)
d_col = ws_postm.Cells(2, ws_postm.Columns.Count).End(xlToLeft).Column
Workbooks("PostSchedule.xlsx").Windows(1).Visible = True
s_rng.Copy ws_postm.Columns(d_col + 1)
With ws_postm
.Cells(1, d_col + 1) = ws_roster.Cells(srow, 1)
.Cells(1, d_col + 2) = ws_roster.Cells(srow, 5)
.Cells(3, d_col + 1) = ws_roster.Cells(srow, 4)
End With
Workbooks("PostSchedule.xlsx").Close SaveChanges:=True
'adjust roster
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: