Home > Software engineering >  Make a copy the contents of the table into another table in the different sheet
Make a copy the contents of the table into another table in the different sheet

Time:11-03

The selected rows in a table, click on the trigger button option box can be designed after the option of copying to another form of different sheet, because form many to very easy to get wrong, so I want to make a macro, don't copy paste,

CodePudding user response:

First to record a macro manually copy and paste (get a method),
Then you need to use option select part of the method of parameter, to
Call this method in the button event,

CodePudding user response:

How the key is not to copy, and paste into another the different sheet in the worksheet, and manually paste to very complicated so I want to have a more simple, can choose an option box ~ which worksheet file name, you can stick to the inside, and need not to,,,,,

CodePudding user response:

You can create a toolbar, the toolbar to add a drop-down box, add the name of each sheet to the drop-down box, paste the sheet from the drop-down box to choose,

CodePudding user response:

After opening or to the operation of the paste, can choose sheet to confirm while directly paste on the table? Save the operation of the paste open? Save the excel table is an essential component of conversion between

CodePudding user response:

To:
 Private Sub test () 
Dim s1 As Worksheet
Dim s2 As Worksheet
Dim Rng As Range

The Set s1=ThisWorkbook. Worksheets (" sheet1 ")
The Set of Rng=Selection
Rng. Copy

The Set s2=ThisWorkbook. Worksheets (" sheet2 ")
S2. Activate
S2. Paste

S1. Activate
End Sub

CodePudding user response:

Can specify the paste to which unit:

 Private Sub test () 
Dim s1 As Worksheet
Dim s2 As Worksheet
Dim Rng As Range

The Set s1=ThisWorkbook. Worksheets (" sheet1 ")
The Set of Rng=Selection
Rng. Copy


The Set s2=ThisWorkbook. Worksheets (" sheet2 ")
S2. Activate
The Set Rng=s2. Cells (1, 1)
Rng. Activate
S2. Paste

S1. Activate
End Sub

CodePudding user response:

6 l code is a little problem:
 Private Sub test () 
Dim s1 As Worksheet
Dim s2 As Worksheet
Dim Rng As Range
The Set s1=ThisWorkbook. Worksheets (" sheet1 ")
The Set of Rng=Selection
Rng. Copy


The Set s2=ThisWorkbook. Worksheets (" sheet2 ")
S2. Activate
S2. Cells (20, 4.) Select

S2. Paste

S1. Activate
End Sub

Choose the area must be square area, don't choose the entire line or the whole column

CodePudding user response:


This is before somebody else to help me write the code, can only stick to the same table, want to change the scarlet letter part to copy to another in different sheets of the table (about 27 sheets), can be directly after artificial selection to confirm to the sheet of paste into the sheet?

Sub Worksheet_BeforeRightClick (ByVal Target As the Range, and Cancel the As Boolean)
Activesheetname=ActiveSheet. Name
Temp1=ActiveCell. Value
Temprow1=ActiveCell. Row
Temp=InputBox (" confirm value ", "value", temp1)

If temp=temp1 Then
Sheets (activesheetname). Rows (temprow1 & amp; ":" & amp; Temprow1). Select
Selection. Copy

tepmrowA=1
Sheets (" the need "). Select
Again1:
If Sheets (" the need ".) Cells (tepmrowA, 1). Valuehttps://bbs.csdn.net/topics/="" Then
Sheets (" the need ".) Cells (tepmrowA, 1). The Activate
ActiveSheet. Paste

The Else
TepmrowA=tepmrowA + 1
GoTo again1
End the If
Sheets (activesheetname). Select
Application. CutCopyMode=False
End the If
End Sub

CodePudding user response:

 If temp=temp1 Then 
Sheets (activesheetname). Rows (temprow1 & amp; ":" & amp; Temprow1). Select
Selection. Copy

Dim As Long I
For I=1 To Sheets. Count
If Sheets (I). The Name & lt;> Activesheetname Then

TepmrowA=1
Sheets (I). Select
Again1:
If Sheets (I) Cells (tepmrowA, 1). Valuehttps://bbs.csdn.net/topics/="" Then
Sheets (I) Cells (tepmrowA, 1). The Activate
ActiveSheet. Paste
The Else
TepmrowA=tepmrowA + 1
GoTo again1
End the If

End the If
Next

Sheets (activesheetname). Select
Application. CutCopyMode=False
End the If

CodePudding user response:


Xlbook. Worksheets (" Sheet2 ") Cells (I, j)=xlbook. Worksheets (" Sheet1 ") Cells (I, j)
Plus 2 cycles, fix

CodePudding user response:

Add a loop Sheets,
Column loop not equal to the entire line copy of high efficiency,

CodePudding user response:

refer to the original poster u010608364 response:
the selected rows in a table, click on the trigger button in the options box can be designed after the option to copy to another form of different sheet, because form many to very easy to get wrong, so I want to make a macro, don't copy paste,


The first to record a macro look at the code, refine, change is about the same.
  •  Tags:  
  • VBA
  • Related