Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting code from a macro (by a macro) | Excel Discussion (Misc queries) | |||
read macro code by vb code | Excel Programming | |||
do anybody have a sample code for executing excel macro from vb code?<eom | Excel Programming | |||
Macro copying macro code | Excel Programming | |||
Macro to change Macro code? | Excel Programming |