×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

copy paste conditionally

copy paste conditionally

copy paste conditionally

(OP)
If column E of sample1.xls matches with column A of sample2.xlsx then look column O of sample1.xls and column P of sample1.xls & if column O of sample1.xls is higher then calculate the 0.50% of column O of sample1.xls or if column P of sample1.xls is higher then calculate the 0.50% of that and multiply the same with column L of sample1.xls(column L can contain - minus sign so ignore that or it will not contain any sign with numbers so we have to look only the numbers) and add that data to Column R of sample1.xls and paste the result to sample2.xlsx from column C(if column C has data then paste to column D and if Column D has then column E and so on)
Vba is placed in a different file
all files are located in same path

sample1.xls and sample2.xlsx has headers so ignore the first row

RE: copy paste conditionally

Hi,

Please post your code and explain where it is you are experiencing difficulty.

You have already been given complete procedures that perform much of what you describe. You must attempt to adapt that code to this task as best you can.

This is Tek TIPS, not Tek CODING.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)

CODE -->

Sub Code()
    Dim wbk1 As Workbook
    Dim wsh1 As Worksheet
    Dim wbk2 As Workbook
    Dim wsh2 As Worksheet
    Dim r1 As Range, vRow2 As Variant, sLookup As String
    
    Application.ScreenUpdating = False
    
    Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\sample1.xls")
    Set wsh1 = wbk1.Worksheets(1)
    
    Set wbk2 = Workbooks.Open(ThisWorkbook.Path & "\sample2.xlsx")
    Set wsh2 = wbk2.Worksheets(1)
    
    With wsh1
        For Each r1 In .Range(.Cells(2, "E"), .Cells(2, "E").End(xlDown))
            sLookup = .Cells(r1.Row, "E").Value
            vRow2 = Application.Match(sLookup, wsh2.Range("A:A"), 0)
                
     
    End With
    
    Application.DisplayAlerts = False
    wbk1.Close SaveChanges:=True
    wbk2.Close SaveChanges:=True
    Application.DisplayAlerts = True
    
    Application.ScreenUpdating = True
End Sub 


i am unable to do the next step plz have a look in it Sir

RE: copy paste conditionally

This is you original post:

CODE

If column E of sample1.xls matches with column A of sample2.xlsx then 
    look column O of sample1.xls and column P of sample1.xls

    if column O of sample1.xls is higher then 
        calculate the 0.50% of column O of sample1.xls or 
    if column P of sample1.xls is higher then 
        calculate the 0.50% of that 

    and multiply the same with column L of sample1.xls

    (column L can contain - minus sign so ignore that or 
    it will not contain any sign with numbers 
    so we have to look only the numbers) 

    and add that data to Column R of sample1.xls and 

    paste the result to sample2.xlsx from column C

    (if column C has data then 
        paste to column D and 
     if Column D has then 
        column E and so on) 

I would first work on this 'pseudo-code' to establish your logic.
For example, first line:
If column E of sample1.xls matches with column A of sample2.xlsx then

What do you mean by "matches" ?
Do you mean all values in column E have to match all values in column A? I.e. E2 = A2, E3 = A3, E4 = A4, and so on...?

And go on down your logic and write it in simple English.
Then you can convert it - line by line - into VBA code.


---- Andy

There is a great need for a sarcasm font.

RE: copy paste conditionally

You did not try hard enough.

Think about it and go on to column O.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
Sir i tried in many ways after that i have posted the same i googled and i saw examples like this problem but i was unsuccessful to resolve the same

RE: copy paste conditionally

If you cannot or will not make this fairly simple association from one example to your task and at least demonstrate that attempt, then you must be in way over your head.

Therefore, you ought to locate a competent VBA coder in your area and hire such an individual to perform this coding and what you will need in the future.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
Sir it will take some time to understand sir i have tried but i am blank about this problem
so plz help i will learn something new about vba from this problem sir so plz help

RE: copy paste conditionally

The ball is in your court.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
the ball is in your court means
Sir u know from the starting that this problem is not like a nornal question thats y i started the post otherwise i am solving the smaller vba problems

RE: copy paste conditionally

You have a tip, a very big tip in the solutions already provided.

Now it is up to you to TRY. Just try to do the next requirement and post it in your code.

When you look at the given solutions, notice that each If has an End If, each For has a Next, each With has an End With.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
Sir we have already use the application.matchlookup of column E and Column A perfectly
i am unable to do from that part

RE: copy paste conditionally

Then you need to hire a coding expert. It will never end.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
Sir i am not a professional guy like u
what i know and what i understand i told u
if i am not understanding what u mean to say then plz provide me the code so that i can learn from the same and from my mistakes

RE: copy paste conditionally

(OP)
If c.Offset(, 15) > c.Offset(, 16) Then
like this will be the next step

RE: copy paste conditionally

Where is c in your code? There is no relationship!

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: copy paste conditionally

(OP)
Sir plz have a look i am blank about this problem

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close