+ Reply to Thread
Results 1 to 21 of 21

Code to write numbers from one cell to another

  1. #1
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Code to write numbers from one cell to another

    I was looking for help to develop some VBA code to write from potentially 4 cells to a possible 4 cells. I have uploaded my sample Excel sheet image with the expected result. If someone could kindly assist.

    The macro would need to start with searching cells B3, B4, E3, E4 to determine if any numbers are present. When found use that number (example cell B3 has a 7 in it) to search for the same number in cells A14, E14, I14, L14 (cell E14 has the 7). When found write the contents from cell C3 (the adjacent cell to the right of the 7 in this example) to cell F14 and change the last number to a 1 (so cell F14 would be written as 8-1). Repeat for each cell B3, B4, E3, E4 and afterwards delete all the contents in B3,C3, B4,C4, E3,F3, E4,F4.

    Thanks in advance for your help.

    EXCEL 5.JPEG

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to write numbers from one cell to another

    You must learn to attach a spreadsheet rather than an image.


    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.



    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-27-2018 at 03:33 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Works but need to make 2 small changes:

    In the Excel example in cell F14 the write is 8-15.1 (should be 8-1) and the cell contents in B3,C3, B4,C4, E3,F3, E4,F4 are not being deleted. I have uploaded my Excel sheet and will so in the future.

    Thanks so much for your help.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Are you still there?

  5. #5
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Code to write numbers from one cell to another

    Try
    Please Login or Register  to view this content.
    "ThankyouFor Attention * And Your Help!!"

  6. #6
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi, it says compile error, Sub or Function not defined and it highlights “isnumeric”.

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to write numbers from one cell to another

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Works great!

    One problem though. How do I expand the
    “TargetA = Split("A6, E6, I6, L6", ", ") line to include more cells and do I have make changes to another line also? I put more cells in followed by a comma but nothing. Nice to see it work though.

    Thank-you for your help.

  9. #9
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi

    Not sure if you received my previous note.
    Thanks

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Code to write numbers from one cell to another

    Don't hardcode the loop boundaries. Use:

    Please Login or Register  to view this content.
    and:

    Please Login or Register  to view this content.
    Rory

  11. #11
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi rorya

    Thanks so much for your response but I have tried putting Ubound(SearchA) in a few places but I don’t think I’m getting it. If you have a minute could you please copy the code to where it belongs. I think this could be a blond moment?

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Code to write numbers from one cell to another

    what additional cells are you talking about?

  13. #13
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Code to write numbers from one cell to another

    my 2 cents:

    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  14. #14
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi everyone

    Thank-you to all 3 of you for your help.
    mehmetcik - your question "what additional cells are you talking about?" is just wanting to add some additional cells to your original code. Your code works perfectly well with the original supplied cells if I want to add some more but I couldn't.

    bulina2k - Your code works as well but I need to also delete the contents in cells "B3:B4, E3:E4" after the write.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Code to write numbers from one cell to another

    Try
    Please Login or Register  to view this content.

  16. #16
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Code to write numbers from one cell to another

    try this work
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Thank-you for your response jindon, I will test out your code.

  18. #18
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    bulina2k I have added srng.ClearContents at the end of the code which works but how do I clear the contents in cells C3:C4 and F3:F4?

    Next
    srng.ClearContents
    End Sub

  19. #19
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Code to write numbers from one cell to another

    like this
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi jindon

    The big issue is that this is hard coded and my sample is just that only a sample. This code will not work in the sheet that I use. I will use the code from bulina2k but I would like to thank-you for your help.

  21. #21
    Registered User
    Join Date
    09-09-2018
    Location
    Vancouver, canada
    MS-Off Ver
    2010
    Posts
    76

    Re: Code to write numbers from one cell to another

    Hi bulina2k

    Your code works so well. A huge Thank-you for all your help!!!!!

+ 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. Find cell with text, offset to the left one cell and write code
    By timas in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-23-2015, 01:22 AM
  2. how can i write vba code for replacing continuos fraction numbers in on row
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-21-2014, 08:04 AM
  3. Code to write to a cell on another sheet
    By neil40 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-23-2013, 04:31 AM
  4. [SOLVED] Code to evaluate contents of one cell then write new values into new cell (Simple IF Stmt)
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2012, 11:54 AM
  5. Write the numbers into one cell
    By kapeller in forum Excel General
    Replies: 0
    Last Post: 02-12-2011, 02:19 AM
  6. Replies: 6
    Last Post: 01-13-2010, 10:26 AM
  7. Replies: 3
    Last Post: 01-10-2005, 08: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