+ Reply to Thread
Results 1 to 5 of 5

If Then copy paste

  1. #1
    Registered User
    Join Date
    05-03-2018
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    2

    If Then copy paste

    Hi all,

    I'm trying to invert two columns if one starts with a certain text, in this case "acc-"

    As you can see, sometimes the column A has the "acc-", while the brand name is in column B and sometimes it's the opposite. I want to put all the brands in column B and the "acc-" in column A.

    I've already tried something with Left(), but the IF THEN is way beyond my skill level. Does anybody have an idea ?

    Thanks in advance

    image.png
    Last edited by Bemir; 05-03-2018 at 05:56 AM.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: If Then copy paste

    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    Via Excel basics :

    PHP Code: 
    Sub Demo1()
             
    Dim Rg As Range
             Application
    .ScreenUpdating False
        
    For Each Rg In ActiveSheet.UsedRange.Columns("A:B").Rows
              
    If Rg.Cells(2).Value Like "acc-*" Then Rg.Value Application.Index(Rg, , [{2,1}])
        
    Next
             Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  4. #4
    Registered User
    Join Date
    05-03-2018
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    2

    Re: Hi ! Try this ‼

    This worked well and can be easily adapted to other cases :-)

    Thanks !

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: If Then copy paste


    Thanks both for the rep' !

+ 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. Replies: 3
    Last Post: 01-01-2015, 06:26 AM
  2. [SOLVED] Copy Paste Loop ends before copy/paste is finished
    By brgr4u in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-08-2013, 04:01 PM
  3. Automate copy and paste and copy and paste back to excel
    By Bmw318be in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2013, 05:42 AM
  4. Automate copy and paste and copy and paste back to excel
    By Bmw318be in forum Access Tables & Databases
    Replies: 0
    Last Post: 02-23-2013, 05:42 AM
  5. Replies: 1
    Last Post: 01-16-2013, 05:36 AM
  6. 2 Macro's: only vertical copy/paste action and copy-paste 14 columns to the right.
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2010, 10:34 AM
  7. Replies: 1
    Last Post: 01-04-2005, 06:06 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