+ Reply to Thread
Results 1 to 5 of 5

Copy value after If

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Copy value after If

    I have number 1 to 10 in Column A and name in Column B. What I am trying to accomplish is to check the name in cell B2, if empty then it will copy the number from cell A2 to cell H2. But if cell B2 already contains a name then it will copy the number from cell A3 to cell H2 and so on.
    here is my code

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Contributor dlow's Avatar
    Join Date
    08-12-2013
    Location
    EveryWhere
    MS-Off Ver
    Excel 2007, 2010
    Posts
    275

    Re: Copy value after If

    Hi,

    You didnt say what doesnt work or what line is giving you trouble. But if I assume correctly try this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Copy value after If

    here is the code that didn't work, it's just show blank
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor dlow's Avatar
    Join Date
    08-12-2013
    Location
    EveryWhere
    MS-Off Ver
    Excel 2007, 2010
    Posts
    275

    Re: Copy value after If

    That code does work, so... Its not working the way you expected.
    Maybe we should have a look @ what you’re doing. I think what you might be getting hung-up on is the Range.Offset Property (Excel).

    So if we look @ this over simplified example:
    Please Login or Register  to view this content.
    We can see how the .Offset Property works. I.E. .Offset(Row, Column).Activate

    What am I saying: it looks like from the code you provided you want to copy data from Col B of some row to H. Well like I said your code does that, & if you’re not see the result you want there is no data in ColB to copy over to H & thats why it looks to you as if nothing is happening, but non the less it is working.

    What I do to make sure what I want is happening is I might add a select just while testing like this:
    Please Login or Register  to view this content.
    Now you see what range you are pointing to. Once you get that worked out now you can replace .select with the .copy Method

  5. #5
    Forum Contributor dlow's Avatar
    Join Date
    08-12-2013
    Location
    EveryWhere
    MS-Off Ver
    Excel 2007, 2010
    Posts
    275

    Re: Copy value after If

    Thanks for the Rep Point. Glad you got it work out.

+ 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. [SOLVED] Change Copy to Copy & Mirror Image the Copy
    By mills49 in forum Excel General
    Replies: 5
    Last Post: 08-21-2014, 05:25 AM
  2. Save copy as, open copy, alter copy, save copy and close copy
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2013, 04:42 PM
  3. [SOLVED] macro error Copy Time format to other Worksheet and continues copy range
    By feroguz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-25-2012, 01:30 PM
  4. Copy one cell to an other but colors do not copy. While not using clipboard to copy.
    By chuckchuckit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2010, 03:08 AM
  5. EXCEL FILE a copy/a copy/a copy ....filename
    By ve in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-29-2005, 05:05 PM

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