2017-04-17 22 views
0

我需要以下代码的帮助。桌面动态路径和数据透视表

它打开保存在用户的桌面文件(即不断变化,从而需要帮助,如何引用有问题的用户的桌面)

还需要保存在新的工作表创建两个数据透视表帮助,

感谢

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

欢迎来到SO。请阅读[如何问](http://stackoverflow.com/help/how-to-ask)。你在一个问题中问了两个非常单独的问题。您会收到更多帮助,提供更明确的问题。 –

回答

0

要获得在用户的桌面上当前登录路径:

Environ("UserProfile") & "\Desktop\Monthly_Report.xlsx"

+0

非常感谢。你能否也请帮忙创建支点和开放的宏工作簿! – ferocious12