+ Reply to Thread
Results 1 to 6 of 6

VB Code For Macro

  1. #1
    Barnie
    Guest

    VB Code For Macro

    I need to build a macro that will copy from whatever cell I have highlited
    and paste to a specific other cell. The idea is that I have entered a control
    button and when pressed the macro is run. Unfortunately I know nothing about
    building it on VB. Could someone give me the code to copy and paste into
    visual basic. I need to do this on multiple buttons so I realise I will have
    to change the destination part of the code. Could you show me where I change
    this.

    Thanks in advance
    --
    Barnie Gumble Esq

  2. #2
    Philip
    Guest

    RE: VB Code For Macro

    Hi,

    The best way for you to learn something like this (the same as for everyone
    - myself included) is to use the Macro recorder on the Tools...Macros menu

    This is always the best way to start when you don't know what objects you
    need...

    When you have finished recording the actions that you need the code for,
    click Stop on the Tools..Macros menu, and use ALT-F8 to show the Macros
    dialog.

    Select the new macro that you just recorded, and choose 'Edit'

    then you can see the code that has been recorded, and this will help you see
    what objects are used, and give you a head start.

    If you are still stuck modifying the code, let uis know and we'll help ...

    HTH

    Philip

    "Barnie" wrote:

    > I need to build a macro that will copy from whatever cell I have highlited
    > and paste to a specific other cell. The idea is that I have entered a control
    > button and when pressed the macro is run. Unfortunately I know nothing about
    > building it on VB. Could someone give me the code to copy and paste into
    > visual basic. I need to do this on multiple buttons so I realise I will have
    > to change the destination part of the code. Could you show me where I change
    > this.
    >
    > Thanks in advance
    > --
    > Barnie Gumble Esq


  3. #3
    Barnie
    Guest

    RE: VB Code For Macro

    I have done that and have got my code. The problem I am now experiencing is
    that when I press the button it does not allow me to paste to the specific
    cell I need. For example I need to be able to copy from any of columns D to I
    and paste only to column L and only for the same row I am copying on.

    Here is the code I have:
    Range("D1").Select
    Selection.Copy
    Range("L1").Select
    ActiveSheet.Paste

    Would it be a case of just changing the range to ("D1,E1,F1,H1,I1,J1")?

    Thanks
    --
    Barnie Gumble Esq


    "Philip" wrote:

    > Hi,
    >
    > The best way for you to learn something like this (the same as for everyone
    > - myself included) is to use the Macro recorder on the Tools...Macros menu
    >
    > This is always the best way to start when you don't know what objects you
    > need...
    >
    > When you have finished recording the actions that you need the code for,
    > click Stop on the Tools..Macros menu, and use ALT-F8 to show the Macros
    > dialog.
    >
    > Select the new macro that you just recorded, and choose 'Edit'
    >
    > then you can see the code that has been recorded, and this will help you see
    > what objects are used, and give you a head start.
    >
    > If you are still stuck modifying the code, let uis know and we'll help ...
    >
    > HTH
    >
    > Philip
    >
    > "Barnie" wrote:
    >
    > > I need to build a macro that will copy from whatever cell I have highlited
    > > and paste to a specific other cell. The idea is that I have entered a control
    > > button and when pressed the macro is run. Unfortunately I know nothing about
    > > building it on VB. Could someone give me the code to copy and paste into
    > > visual basic. I need to do this on multiple buttons so I realise I will have
    > > to change the destination part of the code. Could you show me where I change
    > > this.
    > >
    > > Thanks in advance
    > > --
    > > Barnie Gumble Esq


  4. #4
    evgny
    Guest

    Re: VB Code For Macro

    Hi Barnie
    record, highlited Range("D1:j1") , copy it and paste it to anoder cell
    and you will see.
    Regards
    Yngve


  5. #5
    evgny
    Guest

    Re: VB Code For Macro

    Hi Barnie

    You have to modyfye this macro so it fits for you.


    Sub Makro1()


    Selection.Copy _
    Destination:=Sheets("Your sheets name").Range("B1")




    End Sub

    Regards
    Yngve


  6. #6
    Barnie
    Guest

    Re: VB Code For Macro

    Hey thanks. It's all finally seeming to work.
    --
    Barnie Gumble Esq


    "evgny" wrote:

    > Hi Barnie
    >
    > You have to modyfye this macro so it fits for you.
    >
    >
    > Sub Makro1()
    >
    >
    > Selection.Copy _
    > Destination:=Sheets("Your sheets name").Range("B1")
    >
    >
    >
    >
    > End Sub
    >
    > Regards
    > Yngve
    >
    >


+ 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