+ Reply to Thread
Results 1 to 2 of 2

VBA code (paste data based on some conditions)

  1. #1
    Registered User
    Join Date
    07-01-2020
    Location
    Yerevan
    MS-Off Ver
    2010
    Posts
    44

    VBA code (paste data based on some conditions)

    Hi All,

    I have an excel file (see attached) which is basically a bank statement. I would like to write a vba code such that data is pasted from columns (B to D) to columns (F to H) based on the following conditions:

    1. If the amount in column B is equal to zero, then: 1) Value in Column F is equal to the value in column D AND 2) the value in column G is equal "The company" AND 3) the value is column H is equal to column C

    1. If the amount in column B is greater than zero, then: 1) Value in Column F is equal to text "The company" AND 2) the value in column G is equal to column D AND 3) the value is column H is equal to column B.

    The key here is that either the value of column C or column B in each row is always equal to zero (so the value of column B is 0 or greater than zero), so the logic above should work I just don't know how to write a vba code for this.

    Can someone help me to write a vba code please?

    Many thanks
    Attached Files Attached Files
    Last edited by lilit2222; 07-05-2020 at 05:21 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: VBA code (paste data based on some conditions)

    Is the result in the image below as you expected ?
    EXCEL_2020-07-06_06-07-24.png

    If yes, do you really need to do it with vba ?
    Because the result above is just using a formula in the rows of column F to H.

    column F formula : =IF(B2=0,D2,"The Company")
    column G formula : =IF(B2=0,"The Company",D2)
    column H formula : =IF(B2=0,C2,B2)
    Last edited by karmapala; 07-05-2020 at 06:10 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Code to select column based on a date then perform copy/paste and shade
    By tompee29 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2014, 06:25 AM
  2. Copy and Paste to New Tab based on Conditions
    By mattman123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-24-2014, 12:59 PM
  3. Replies: 0
    Last Post: 10-29-2013, 09:38 AM
  4. [SOLVED] Copy and Paste Based on Conditions
    By Hazarrd in forum Excel Programming / VBA / Macros
    Replies: 36
    Last Post: 10-14-2013, 05:44 PM
  5. Replies: 2
    Last Post: 06-15-2012, 04:40 PM
  6. Cut & Paste Multiple Sheet Conditions Macro Code-Check
    By BrokenHero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2009, 01:26 AM
  7. Copy and Paste based on conditions
    By K17TROJAN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2008, 01:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1