我想要复制一个首先在列表中倒计时的偏移单元格。
我倒计时,直到结束+1,在右侧,然后从那里到DOWN,LEFT单元的偏移。我想要复制到另一个文件的单元格中的那个数字
这是不起作用的代码。 我知道我使用了很多选择和选择,这可能是它无法正常工作的原因。
Workbooks("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
Range("B333").Select
Selection.Copy
Windows("Technology Purchase Order Template V4.xlsm").Activate
Sheets("PO Authorization").Select
Range("B5").Select
ActiveSheet.Paste
答案 0 :(得分:0)
将Window
替换为Workbooks
:
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
,也许Sheets
与Worksheets
答案 1 :(得分:0)
使用
Workbooks.open("Technology Purchase Order Template V4.xlsm").Activate
而不是
Windows("Technology Purchase Order Template V4.xlsm").Activate
如果您想隐藏开始/结束流程,请查看以下答案: Open Excel file for reading with VBA without display
答案 2 :(得分:0)
Sry那不是程序......这就是我的意思:
Workbooks.Open("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
Selection = Worksheets("2015").Cells(Worksheets("2015").Rows.Count, "C").End(xlUp).Row
Selection.Offset(1, -1).Copy
Workbooks.Open("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("PO Authorization").Select
Range("B5").Select
ActiveSheet.Paste
Sheets("SBB").Select
Range("A2:W2").Select
Selection.Copy
Workbooks.Open("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
Selection = Cells(Worksheets("2015").Rows.Count, "C").End(xlUp).Row + 1
Selection.PasteSpecial Paste:=xlPasteValues
有人可以解决这个问题....你可以看到我想将偏移单元复制到一个文件中,并从该文件中将一系列单元格复制到列表底部,并带有此Count(xlUp或xlDown)函数。
我希望有人能解决这个问题!
埃里克
答案 3 :(得分:0)
这是正确的代码!
还有一些功能,所以不要怀疑。
Sub All_to_PDF_File()
Dim Filename As String
Dim sFile As String, sPath As String
Dim wBook As Workbook
Dim x As Long
Dim y As Long
On Error Resume Next
Set wBook = Workbooks("Purchase Order Details for FY 2015.xlsx")
If wBook Is Nothing Then 'Not open
MsgBox "Please Open 'Purchase Order Details for FY 2015.xlsx' before running this macro!!"
Set wBook = Nothing
On Error GoTo 0
Else 'It is open
Workbooks("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
With ActiveSheet
y = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
Range("B" & y + 1).Select
Selection.Copy
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("PO Authorization").Select
Range("B5").Select
ActiveSheet.Paste
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("SBB").Select
Range("A2:W2").Select
Selection.Copy
Workbooks("Purchase Order Details for FY 2015.xlsx").Activate
Worksheets("2015").Select
With ActiveSheet
x = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
Range("C" & x + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Workbooks("Technology Purchase Order Template V4.xlsm").Activate
Worksheets("PO Authorization").Select
'Call the function with the correct arguments
Filename = RDB_Create_PDF(ActiveWorkbook, "", True, True)
'For a fixed file name and overwrite it each time you run the macro use
'RDB_Create_PDF(ActiveWorkbook, "C:\Users\Ron\Test\YourPdfFile.pdf", True, True)
If Filename <> "" Then
'Ok, you find the PDF where you saved it
'You can call the mail macro here if you want
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
End If
End Sub