+ Reply to Thread
Results 1 to 5 of 5

Macro to copy cell value if.......

  1. #1
    Registered User
    Join Date
    04-27-2017
    Location
    oxford
    MS-Off Ver
    2010
    Posts
    5

    Macro to copy cell value if.......

    Hi everyone,

    Can someone help with creating a code to run for this task, (I don't think it is possible without VBA but I am a beginner).

    So in range (B2:Bxxxx), run down the range one cell at a time,
    Condition 1. If the cell is blank and the adjacent cell in column A is blank then move down to the next cell in column B
    Condition 2. If the cell in column B already contains a text move to the next cell down,
    Condition 3. If the cell is blank and the adjacent cell in column A contains a value then copy the text in the cell above from column B and move down
    The gaps between the products shouldn't be more than 15 rows so if Condition 1 is repeated more than 15 times, STOP.

    this is how it looks now

    A B

    20 Apple
    10


    40 Banana
    60
    170
    80



    30 Orange
    60
    10

  2. #2
    Registered User
    Join Date
    04-27-2017
    Location
    oxford
    MS-Off Ver
    2010
    Posts
    5

    Re: Macro to copy cell value if.......

    I want it to look like this

    A B

    20 Apple
    10 Apple


    40 Banana
    60 Banana
    170 Banana
    80 Banana


    30 Orange
    60 Orange
    10 Orange

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,017

    Re: Macro to copy cell value if.......

    The following doesn't populate the missing values in column B instead it populates columns D:E, however, perhaps it will be of some help.
    With columns A:B filled as shown in post #1, starting with row 2, paste the following into D2: =IF(A2<>"",A2,"")
    Paste the following into E2: =IF(A2="","",IF(AND(A2<>"",B2<>""),B2,E1))
    Copy the formulas down as far as needed.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  4. #4
    Registered User
    Join Date
    04-27-2017
    Location
    oxford
    MS-Off Ver
    2010
    Posts
    5

    Re: Macro to copy cell value if.......

    Hi JeteMc,

    thanks for the reply, I recorded a new macro, input the formula and some copying, pasting and deleting and all seems to be good. As long as it works with one click I am happy, which it now seems to.

    Thank you.

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,017

    Re: Macro to copy cell value if.......

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools drop down in the ribbon above your first post. I hope that you have a blessed day.

+ 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: 1
    Last Post: 07-22-2015, 05:23 PM
  2. Replies: 3
    Last Post: 04-04-2014, 11:34 AM
  3. Replies: 1
    Last Post: 01-03-2014, 03:01 AM
  4. Replies: 1
    Last Post: 11-06-2013, 02:56 AM
  5. [SOLVED] Macro copy entire row if any cell frm col A in sheet1 match any cell frm col A in sheet2
    By daillest319 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2013, 03:20 PM
  6. [SOLVED] Macro to copy cell width to new sheets (ie copy original sheet format)
    By teenyjem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-20-2013, 07:28 AM
  7. [SOLVED] Macro to find text and if found, copy an adjacent cell into a different cell
    By Raulus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-22-2012, 09:57 AM

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