[英]Excel VBA - Function to check a specific sheet and named cell exists in workbook
[英]VBA sheet to new workbook if specific cell populated
我建立了一个宏,该宏可以将工作表中的单个工作表复制到新工作簿中,并将新工作簿保存在特定位置。 我已经建立了我的源文件,并且有3张纸(共6张),可能需要将其添加到新保存的文件中。
我想将工作表4(原始)工作表保存到新文件,然后查看工作表2,如果c2有特定结果,则将工作表移至新文件,然后查看工作表17,如果c2有特定结果,将工作表移到新文件。
并保存。
我的努力在于引用一个特定的单元来调用操作。
我的努力在于引用一个特定的单元来调用操作。
您可以使用按钮并在其上分配创建的宏,以触发操作。
@urdearboy
Sub Cleanup()
'
' Cleanup Macro
'
' Keyboard Shortcut: Ctrl+e
'
'This is some clean up stuff on a specific tab, somewhere after this I need to add the check of a specific cell and pull the full sheet.
Application.ScreenUpdating = False
'Get path for desktop of user PC
Path = Environ("USERPROFILE") & "\Desktop"
Sheets("Uploader").Cells.Copy
'Create new workbook and past copied data in new workbook & save to desktop
Workbooks.Add (xlWBATWorksheet)
ActiveWorkbook.ActiveSheet.Paste
ActiveWorkbook.ActiveSheet.Name = "Upload"
x = Weekday(Date, vbSaturday)
Select Case x
Case 1
x = 2
Case 2
x = 3
Case Else
x = 1
End Select
ActiveWorkbook.SaveAs Filename:=Path & "\" & "Upload " & Format(CStr(Date - x), "mmddyyyy") & ".xlsx"
' start email
Dim Outlook As Object, EMail As Object
Set Outlook = CreateObject("Outlook.Application")
Set EMail = Outlook.CreateItem(0)
With EMail
.To = "1"
.CC = "2"
.BCC = ""
.Subject = "File is Ready"
.Body = "Isn't Automation Amazing!?"
.Attachments.Add ActiveWorkbook.FullName ' To add active Workbook as attachment
'.Attachments.Add "" ' To add other files just use path, Excel files, pictures, documents pdf's ect.
.Display 'or use .Send to skip preview
End With
Set EMail = Nothing
Set Outlook = Nothing
'end email
ActiveWorkbook.Close savechanges:=True
Application.ScreenUpdating = True
ActiveWorkbook.Close savechanges:=False
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.