1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Coping a Row to Another row that is selected

Discussion in 'Business Applications' started by Galstar, Feb 14, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. Galstar

    Galstar Thread Starter

    Joined:
    Feb 14, 2007
    Messages:
    23
    I am trying to create a macro that can copy for me.

    User selects a row(any row) so the code must look to see what row the user selected.

    Takes another row(i.e 1451) and copies it

    Then takes and pastes the row say 1451 onto the row selected by user. I want the formatting to be copied and any formula's.
     
  2. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Rows(1451).Copy Cells(ActiveCell.Row, 1)

    BUT ...

    it depends on the formulas in 1451. If C1451 contains (e.g.) =C1450 and the selected row is 1, then you'll end up with =#REF! in C3. So, more info perhaps? :)

    EDIT: welcome to the board. :)
     
  3. Galstar

    Galstar Thread Starter

    Joined:
    Feb 14, 2007
    Messages:
    23
    Thank.

    I insert a row and type in a name into Col A, and then data say into C, I then want the above function to only copy formatting, formula's etc. I don't want to copy the contents per say. in your example it blanks out all data entered. The formula is specific in this instance. $d$1(repsents a date) - $D6 (repsents a date started) so it will give me the numbers of days since the start date. The date in D1 changes. So the value of D6 needs to be the row of the selection itself. I.e based upon your example, if I selct row 101 the formula would change to $D$1 - $D101.
     
  4. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Not at all -- it will overwrite the data entered, rather than blank it out. But then you weren't clear on your requirements.

    Do you mean you want cells from only some of the columns (of 1451) copied to the active row? Exactly what you need would be helpful. :)
     
  5. Galstar

    Galstar Thread Starter

    Joined:
    Feb 14, 2007
    Messages:
    23
    Yes, but what I really want, is that I have a standard line that is correctly formmated, and has formulas that need to be in any row that is inserted up running a macro. So to answer your question. Yes the formula that is Col D is the most important, but I would alsol like the formatting from A, B applied as well.

    Sorry new to this, am trying to explain it clearly for you.
     
  6. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    Err, OK. :confused:

    ...

    You can copy the formats from 1451 with this, if that helps.

    Sub test()
    Rows(1451).Copy
    Cells(ActiveCell.Row, 1).PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    End Sub
     
  7. Galstar

    Galstar Thread Starter

    Joined:
    Feb 14, 2007
    Messages:
    23
    That work. So taking just a bit farther if you don't mind.

    Same senireo, but I do only want to copy cetain cells instead. Also could this coping be done upon just a plain insert row?
     
  8. Galstar

    Galstar Thread Starter

    Joined:
    Feb 14, 2007
    Messages:
    23
    If I try to use Macro more than once,it doesn't paste anything after doing it once. I am using your exact code, I select a row and it copies forulmas no problem, go to another row and it highlights it like its going to, but never copies it again. I have to save file and start over then it works once.
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/544007

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice