Akash kothari
Member
Hello Friends,
I have created one small macro which copy data from main file to other sub file based on column E named as "CRM"
within subfiles you can find these CRM as sheets names.
I did it for 1 CRM but how to do the same for multilple CRM in different workbook.
Can anyone advise please
Thank you
Akash
Code that i created (attached the files)
Sub Button1_Click()
lastrow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, 5) = "Catherine Mclaughlin" Then
Range(Cells(i, 1), Cells(i, 10)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Documents and Settings\e560228\Desktop\New Folder\New Folder\CRM\20131014 - CRM Event Log- London.xlsx"
Dim p As Integer, q As Integer
p = Worksheets.Count
For q = 1 To p
If ActiveWorkbook.Worksheets(q).Name = "Catherine Mclaughlin" Then
Worksheets("Catherine Mclaughlin").Select
End If
Next q
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub
I have created one small macro which copy data from main file to other sub file based on column E named as "CRM"
within subfiles you can find these CRM as sheets names.
I did it for 1 CRM but how to do the same for multilple CRM in different workbook.
Can anyone advise please
Thank you
Akash
Code that i created (attached the files)
Sub Button1_Click()
lastrow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, 5) = "Catherine Mclaughlin" Then
Range(Cells(i, 1), Cells(i, 10)).Select
Selection.Copy
Workbooks.Open Filename:="C:\Documents and Settings\e560228\Desktop\New Folder\New Folder\CRM\20131014 - CRM Event Log- London.xlsx"
Dim p As Integer, q As Integer
p = Worksheets.Count
For q = 1 To p
If ActiveWorkbook.Worksheets(q).Name = "Catherine Mclaughlin" Then
Worksheets("Catherine Mclaughlin").Select
End If
Next q
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells(erow, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
End Sub