Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA - Copying button down multiple rows whilst keeping relative positioning

Status
Not open for further replies.

Marco123

Programmer
Dec 31, 2010
23
GB
Hi all,

I have several buttons in a row on a spreadsheet that I am trying to copy down multiple rows in VBA.

I know how to copy a button in VBA with the following code:

Code:
ws.Shapes("Button 1").Copy
ws.Range("J10").Select
ws.Paste

From this code, it is easy to loop it to copy down the button multiple rows. However, it copies the button to the left hand side of the cell each time and loses the original positioning (in the centre of the cell) of the first button. Therefore, I am trying to find out how to copy the buttons whilst keeping the original positioning relative to the cell of the button I am trying to copy.

Any ideas? It needs to be scalable to say copy down 50 rows.

Thanks all.
 
It's possible to read shape's Width and Height and range's Left, Top, Width and Height. Basing on this calculate and set Left and Top for copied shape.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top