• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Convert an equation for transferring data from one file to another separate file to Vba Code

Hany ali

Active Member
Hello my dear,i want Your Help to Convert this Equation to Vba Code ,to Moving Data from Workbook (BikoData.xlsx ) to another workBook (Weekly Report For Profit.xlsm)
Code:
=IFERROR(IF(INDEX('C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!$A$2:$AM$1000,ROWS(A$1:A1),MATCH(B$1,'C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!$A$1:$AM$1,0))=0,"",INDEX('C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!$A$2:$AM$1000,ROWS(A$1:A1),MATCH(B$1,'C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!$A$1:$AM$1,0))),"")
This equation made the file very heavy and I hope to find a suitable code for transferring data as this equation works under the same conditions .. by as the Same this Headers

 

Attachments

  • 1.png
    1.png
    33.1 KB · Views: 4
  • BikoData.xlsx
    14.9 KB · Views: 2
  • Weekly Report For Profit.xlsm
    99.7 KB · Views: 4
sorry my dear
Please Delete Empty File From Main Post and Paste This File instead of it in Main Post
 

Attachments

  • BikoData.xlsx
    20.8 KB · Views: 3
Last edited:
If, in your real files you have a column headed Voucher in the Data sheet then
Code:
Sub blah()
    Set wbSce = Workbooks.Open("C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\BikoData.xlsx", ReadOnly:=True)
    Workbooks("BikoData.xlsx").Sheets("Data").Range("A1:AM1000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ThisWorkbook.Sheets("Basic").Range("B1:S1"), Unique:=False
    wbSce.Close False
End Sub
might do it.
 
…otherwise:
Code:
Sub blah2()
 With Sheets("Basic").Range("B2:S500")
 .FormulaR1C1 = "=IFERROR(IF(INDEX('C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!R2C1:R1000C39,ROWS(R1C[-1]:R[-1]C[-1]),MATCH(R1C,'C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!R1C1:R1C39,0))=0,"""",INDEX('C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!R2C1:R1000C39,ROWS(R1C[-1]:R[-1]C[-1]),MATCH(R1C,'C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\[BikoData.xlsx]Data'!R1C1:R1C39,0))),"""")"
 .Value = .Value
 End With
End Sub
 
I only used the same path as in your first message, if you've moved it then you need to update the code yourself.
Workbooks.Open("C:\Users\hany.ali\Desktop\Weekly Report For Profit - Copy\BikoData.xlsx"
66910
 
I tested both code snippets here, they worked; (the first code snippet I provided needed to see the persence of a Voucher column in the source data).
You just need to get your file locations 100% correct.
I notice there's a dot between hany and ali - but only sometimes.
 
The first code worked with me by this way
Code:
Sub blah()
   Set wbSce = Workbooks.Open("C:\Users\hany ali\Desktop\Weekly Report For Profit\BikoData.xlsx", ReadOnly:=True)
   Workbooks("BikoData.xlsx").Sheets("Data").Range("A1:AM1000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ThisWorkbook.Sheets("Basic").Range("B1:S1"), Unique:=False
  wbSce.Close False
End Sub
thanks alot my dear allready i used first code and now work well
Really unable to thank you - that's exactly what is needed
I got tired of you so much with me
 
Back
Top