我需要以下代码的帮助。
它会打开一个保存在用户桌面上的文件(不断变化所以需要帮助,如何引用相关用户的桌面)
还需要帮助创建保存在新工作表上的两个数据透视表,
由于
Sub CFilter()
' open Monthly report workbook saved on desktop of the user (changes everytime - need help to get to select desktop path)
Workbooks.Open "C:\Users\**xxxxx**\Desktop\Monthly_Report.xlsx"
' copy the only sheet saved in Monthly report workbook
Sheets(1).Copy
' Activate Workbook Macro (this contains this macro) & paste the sheet (need code for that)
Workbooks("Macro.xlsm").Paste
' Following code separate the contents of column E and separate the names separated by comma to separate columns starting column L
Dim N As Long, wf As WorksheetFunction
Set wf = Application.WorksheetFunction
N = Cells(Rows.Count, "E").End(xlUp).Row
Dim i As Long, j As Long, k As Long
For i = 1 To N
ary = Split(wf.Trim(Cells(i, "E").Text), ",")
k = 2
For j = LBound(ary) To UBound(ary)
Cells(i, k).Value = ary(j)
k = k + 1
Next j
Next i
' need code here that create a pivot in another worksheet and only include rows from existing worksheet where column L is blank (need help)
' need code here that create a pivot in another worksheet and only include rows from existing worksheet where column K is blank (need help)
End Sub`
答案 0 :(得分:0)
获取当前登录用户桌面的路径:
Environ("UserProfile") & "\Desktop\Monthly_Report.xlsx"