+ Reply to Thread
Results 1 to 7 of 7

How to write a function or macro to copy

  1. #1
    RandEman
    Guest

    How to write a function or macro to copy

    Please help...

    I need to know how to write a function or macro to copy the contents of cell
    (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).

    i.e. A1 copied to C1; B1 copied to the comments of C1

    Thanks for your help

  2. #2
    Gary's Student
    Guest

    RE: How to write a function or macro to copy

    Try this:

    Sub temp()
    Cells(1, 3).Value = Cells(1, 1).Value
    Cells(1, 3).AddComment
    Cells(1, 3).Comment.Text Text:=Cells(1, 2).Value
    End Sub

    Its pretty neat. You can insert or modify all cells in a range with this
    kind of technique

    Have a good day!
    --
    Gary's Student


    "RandEman" wrote:

    > Please help...
    >
    > I need to know how to write a function or macro to copy the contents of cell
    > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    >
    > i.e. A1 copied to C1; B1 copied to the comments of C1
    >
    > Thanks for your help


  3. #3
    RonaldF
    Guest

    RE: How to write a function or macro to copy

    'Copies the contents of A1 to C1
    Range("C1") = Range("A1")

    --
    Ronald Ferdinandus
    http://www.ro-pay.nl


    "RandEman" wrote:

    > Please help...
    >
    > I need to know how to write a function or macro to copy the contents of cell
    > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    >
    > i.e. A1 copied to C1; B1 copied to the comments of C1
    >
    > Thanks for your help


  4. #4
    RandEman
    Guest

    RE: How to write a function or macro to copy

    Thank you very much...

    I have a dumb question: Does this need to be run as a macro or a function?

    Thank you again for your help!


    "Gary's Student" wrote:

    > Try this:
    >
    > Sub temp()
    > Cells(1, 3).Value = Cells(1, 1).Value
    > Cells(1, 3).AddComment
    > Cells(1, 3).Comment.Text Text:=Cells(1, 2).Value
    > End Sub
    >
    > Its pretty neat. You can insert or modify all cells in a range with this
    > kind of technique
    >
    > Have a good day!
    > --
    > Gary's Student
    >
    >
    > "RandEman" wrote:
    >
    > > Please help...
    > >
    > > I need to know how to write a function or macro to copy the contents of cell
    > > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    > >
    > > i.e. A1 copied to C1; B1 copied to the comments of C1
    > >
    > > Thanks for your help


  5. #5
    RandEman
    Guest

    RE: How to write a function or macro to copy

    One more question, I need to run this accross several sheets in a workbook,
    how would I do that?

    "Gary's Student" wrote:

    > Try this:
    >
    > Sub temp()
    > Cells(1, 3).Value = Cells(1, 1).Value
    > Cells(1, 3).AddComment
    > Cells(1, 3).Comment.Text Text:=Cells(1, 2).Value
    > End Sub
    >
    > Its pretty neat. You can insert or modify all cells in a range with this
    > kind of technique
    >
    > Have a good day!
    > --
    > Gary's Student
    >
    >
    > "RandEman" wrote:
    >
    > > Please help...
    > >
    > > I need to know how to write a function or macro to copy the contents of cell
    > > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    > >
    > > i.e. A1 copied to C1; B1 copied to the comments of C1
    > >
    > > Thanks for your help


  6. #6
    Gary's Student
    Guest

    RE: How to write a function or macro to copy

    I prefer a macro rather than a function. A macro can change lots of things.
    I don't know how to make a function change both the value and the comment.

    If you put the code in a module rather than worksheet code, then it should
    work in any worksheet you have active.


    Update this post if your have anymore questions on this topic. Otherwise:


    Have a good weekend
    --
    Gary's Student


    "RandEman" wrote:

    > One more question, I need to run this accross several sheets in a workbook,
    > how would I do that?
    >
    > "Gary's Student" wrote:
    >
    > > Try this:
    > >
    > > Sub temp()
    > > Cells(1, 3).Value = Cells(1, 1).Value
    > > Cells(1, 3).AddComment
    > > Cells(1, 3).Comment.Text Text:=Cells(1, 2).Value
    > > End Sub
    > >
    > > Its pretty neat. You can insert or modify all cells in a range with this
    > > kind of technique
    > >
    > > Have a good day!
    > > --
    > > Gary's Student
    > >
    > >
    > > "RandEman" wrote:
    > >
    > > > Please help...
    > > >
    > > > I need to know how to write a function or macro to copy the contents of cell
    > > > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    > > >
    > > > i.e. A1 copied to C1; B1 copied to the comments of C1
    > > >
    > > > Thanks for your help


  7. #7
    Curt
    Guest

    RE: How to write a function or macro to copy

    is there a way to take the results of a formula out of a workbook to another
    location and still retain the formula in cells? Want the active workbook to
    retain formulas or must they be reentered by vba code?
    Thanks
    [email protected]

    "Gary's Student" wrote:

    > Try this:
    >
    > Sub temp()
    > Cells(1, 3).Value = Cells(1, 1).Value
    > Cells(1, 3).AddComment
    > Cells(1, 3).Comment.Text Text:=Cells(1, 2).Value
    > End Sub
    >
    > Its pretty neat. You can insert or modify all cells in a range with this
    > kind of technique
    >
    > Have a good day!
    > --
    > Gary's Student
    >
    >
    > "RandEman" wrote:
    >
    > > Please help...
    > >
    > > I need to know how to write a function or macro to copy the contents of cell
    > > (A1) to cell (C1) and contents of a cell (B1)to the comments of cell (C1).
    > >
    > > i.e. A1 copied to C1; B1 copied to the comments of C1
    > >
    > > Thanks for your help


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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