How can I copy data from a cell to other cells on same line, testing that they are em

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patricun
    New Member
    • Nov 2012
    • 1

    How can I copy data from a cell to other cells on same line, testing that they are em

    Eg Copy A1 to B1 but if B1 is occupied try C1, etc until an empty cell on line 1 is found.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    This is for MS-Excel yes?
    Several ways to do this...
    My way is to set the home cell and store the value
    then use the offset from there to find an empty cell

    Please post what you have tried so far remembering to format your code using the <CODE/> button.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      1. Move the selection cursor to cell A1.
      2. Is the value empty?
      3. Yes. All done. Write value here.
      4. No. Using ActiveCell.Offs et(0, 1) check cell B1. Is the value empty?
      5. Yes. All done. Write value here.
      6. No. All done. Write the value in ActiveCell.End( xlToRight).Offs et(0,1).

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Why not just line 6?

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          Because it wouldn't work for either of the other two situations. That seems rather obvious. Is that really the question you meant to ask?

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            It seems to me the OP only has one scenario. Copy one cell to the first blank cell to the right of said cell.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #7
              :Confused:
              ... and that would not be achieved by using line #6 alone - but would be by following the steps as outlined.

              This seems very straightforward to me. Am I missing something?

              Comment

              • zmbd
                Recognized Expert Moderator Expert
                • Mar 2012
                • 5501

                #8
                That is what I gathered from OP's post too... kinda reminds me of a homework assignment which is why I asked for OP's code.
                Normally I do this with range names and gotos to move imported data from one spot to another... then I found the transferworkshe et method and YEA done on the export!

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  Originally posted by Zmbd
                  Zmbd:
                  then I found the transferworkshe et method and YEA done on the export!
                  Now you're confusing me Z. This is about identifying which cell in row 1 is the first blank one from the left. My thought was to use the Ctrl-Arrow approach which skips from one end of a block of cells to the other. Clearly there's no call for skipping across if A1 is already a free cell. If A1 has data but is only one cell wide (IE. B1 is empty) then Ctrl-RightArrow takes it across to the next block (which does us no good), so we have to allow for that.

                  Hence post #3 which lays out all the necessary steps in order to be guaranteed to find the first empty cell of the row.

                  Comment

                  • zmbd
                    Recognized Expert Moderator Expert
                    • Mar 2012
                    • 5501

                    #10
                    Let's see what OP has for us to work with... between us we've given the information needed to solve the question.
                    Besides, it strikes me as an homework question the more I read it.

                    Comment

                    • Rabbit
                      Recognized Expert MVP
                      • Jan 2007
                      • 12517

                      #11
                      I see now, I forgot that if it starts near a blank cell, it jumps to the very end of the spreadsheet.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32633

                        #12
                        Indeed. If the cell to the right is blank then it will go to the next non-blank cell on its right. If there are no more in the row then it will go to the far-right cell of the row.

                        This behaviour can be seen and experimented with by using the Ctrl key with one of the arrow keys or else pressing the End key followed by one of the arrow keys.

                        Comment

                        Working...