Copy & Paste if condition met with calculation

Copy & Paste if condition met with calculation

Anonymous
Not applicable
1,131 Views
1 Reply
Message 1 of 2

Copy & Paste if condition met with calculation

Anonymous
Not applicable

Hi Experts,
I am looking for a macro that will do the things mentioned below

there are 3 files 1.xls & BasketOrder.xlsx & macro.xlsm (macro will be placed in macro.xlsm),both files are loacted in diffrent places so the path will be hardcoded in the macro so that i can change it as per my needs
sheet name can be anything
plz see the sample file


If column C of basketorder.xlsx matches with column B of 1.xls & Column J is BUY then add 0.05 to column D of 1.xls & compare column L of basketorder.xlsx with column D of of 1.xls & if column D of 1.xls is lower then Column L of basketorder.xlsx then replace column L data with column D data OF 1.xls

If column C of basketorder.xlsx matches with column B of 1.xls & Column J is SELL then subtract 0.05 to column D of 1.xls & compare column L of basketorder.xlsx with column D of of 1.xls & if column D of 1.xls is greater then Column L of basketorder.xlsx then replace column L data with column D data OF 1.xls


Thnx for the Help 

0 Likes
1,132 Views
1 Reply
  • VBA
Reply (1)
Message 2 of 2

grobnik
Collaborator
Collaborator

Hi @Anonymous 

Even if I'm not moderator inside this forum, I guess you post your issue in a wrong forum, due to this forum it's related to VBA of course, but the application it's not Excel but it's Autocad, or on the opposite you are using EXCEL for populating an Autocad table or some other drawing related, in this case you are in the right forum.

In any case, let me allow to suggesting you some way with you can fix your issue in easy way using Range function and scan all cells with a for next cycle.

Below Just an example:

 

 

 

For Each MyCella In Workbooks("1.xls").Sheets(1).Range("J2:J100")
    MyValue = MyCella .Value
    MyRow = MyCella.Row
    For Each MyCella2 In Workbooks("BasketOrder.xlsx").Sheets(1).Range("A2:A100")
        If StrComp(MyCella .Value, MyCella2.Value, vbTextCompare) = 0 Then
            If   Workbooks("1.xls").Sheets(1).Range("J" & MyRow) = "BUY" then ' Column J is BUY CHECK if cell value is "BUY"
            Workbooks("1.xls").Sheets(1).Range("D" & MyRow) = Workbooks("1.xls").Sheets(1).Range("D" & MyRow)+0,05
        End If
 end if
    Next
Next

 

 

I'm sorry all above it's just an example, you could take it as way to follow to solve your issue.

Of course check and update, in case workbook file name and related sheet.

I'm not a professional programmer, it's just an hobby.

I hope you will find solution to your issue easy.