ActiveX Command Button Problem

cgfrank

Board Regular
Joined
Jun 9, 2014
Messages
51
This is my first attempt at using vba or activex controls so please bear with me.

I created a command button in my document to use a macro (that I recorded) to copy these 2 boxes (merged) and duplicate them. It works well, but the new boxes appear above the old ones (where I drew the red line in this picture). I want them to appear below (as seen in the picture).

When I recorded the macro, I selected the "Action Item" cell and the one beside it to the right, copied it, inserted it below, and it worked. For some reason when I run the macro it inserts it above.

Can anyone help me understand why this is happening? I want it to appear below.

Thanks in advance.
ozke3sf57
example.png
[/URL]screenshot windows[/IMG]
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It would help if you post the VBA
Click on the code tags icon # (above post window) and paste your code between the tags

thanks
 
Upvote 0
Code:
Sub ActionTDG()'
' ActionTDG Macro
'


'
    Range("ActionTDG1:ActionTDG4").Select
    Selection.Copy
    Range("ActionTDG1").Select
    Selection.Insert Shift:=xlDown
End Sub
 
Upvote 0
Try putting the cursor in the cell where paste is required and then running this

Code:
Sub ActionTDG()
    Range("ActionTDG1:ActionTDG4").Copy
    ActiveCell.Insert Shift:=xlDown
End Sub
 
Upvote 0
1. Can you please explain exactly what this range is
Code:
Range([COLOR=#ff0000]"ActionTDG1:ActionTDG4[/COLOR]").Select

2. Please explain exactly what these 2 boxes (merged) are
- how were they created, are they textboxes, if so which type etc

thanks
 
Upvote 0
Those two cells are cells spanning that row (ActionTDG1 is the defined name of the leftmost cell and ActionTDG4 is the defined name of the rightmost cell).
They were created by merging several cells into one larger text box, and then right click > define name.
 
Upvote 0
:confused: It is not possible to merge several cells into one larger textbox
- several cells can be merged into a single merged cell
- cells cannot be merged into textboxes - in Excel they are totally different objects
- they are either cells or textboxes but cannot be both

I think you are talking about merged cells

In which case, this is the code that you need
Code:
Sub ActionTDG1()
    Range(Range("ActionTDG1").MergeArea, Range("ActionTDG4").MergeArea).Copy
    ActiveCell.Insert Shift:=xlDown
End Sub

Select the cell that you want to paste into and run the code

Good luck :)
 
Last edited:
Upvote 0
Thanks for all your help! I achieved what I wanted with a combination of your advice and ActiveCell.Offset(1).Select
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top