Question:
Excel copy Button from one sheet to another? Code?
?
2011-06-16 04:14:22 UTC
Basically it is a DB table on one sheet, Search engine on the other and on the third i want to make the searched result table, that will be filled with results by pressing a certain COPY button on the second sheet (search engine sheet).
The thing is i am not so good in VBA, and don't know how can i make excel to look if this row is already filled with info than turn to next row (if empty - paste special "values")
The search engine sheet is a simple sheet, that uses vlookup and gives the necessary results in one row for example c3;d3;e3;f3 are being filled with info when you select something from a drop-down list.
Near that search result fields i want to make a button that will copy theses cells c3;d3;e3;f3 and paste them in the result sheet, but not one on top of another - i want the macro to understand if the 1;2;3;4;5..... rows are filled already and paste the info in to the next available.

What would be the VBA code for this ? :)
Three answers:
garbo7441
2011-06-16 05:29:01 UTC
Edit: Sorry, I forgot to advise you to change the "Sheet3" reference in the code to your actual sheet name, i.e. "Result"... then follow the procedure as indicated.



=============





Assuming your 'result' sheet is named 'Result', the following macro will do as you wish.



Copy this to the clipboard:



Sub Copy_Range()

Range("C3:F3").Copy Destination:= _

Sheets("Sheet3").Range("A" & Rows.Count). _

End(xlUp).Offset(1)

End Sub



Press ALT + F11



In the menus at the top of the VBE, select INSERT > MODULE



Paste the macro into the editing area to the right.



Close the VBE and return to the worksheet.



For Excel 2003:



If the Forms toolbar is not visible, go to View > Toolbars and select 'Forms'.



Once displayed, click the button icon and click and drag a button onto the worksheet.



The 'Assign Macro' window will open.



Select the macro and click 'OK'.



Drag the button to the desired location and size it by dragging a corner diagonally. Right click the button and select 'Edit text'. Change 'CommandButton1' to the name you wish to use. Click any cell to close 'design' mode.



For Excel 2010, the command button is created from the Developer tab, using the Insert dropdown in the Controls group.
rosenstock
2017-01-19 19:05:07 UTC
Copy Button In Excel
2016-02-29 07:31:10 UTC
Can you paste the error message that you receive and which line of code is highlighted it when you debug it?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...