I've been trying to create a VBA macro that when I click on a certain cell (in excel), the information on another worksheet can get copied into the designated cells.
For instance, if I click on A1 in Worksheet1, then B20:C20 on worksheet3 is copied to B20:C20 of Worksheet2. Can anyone help me create this macro?
Try to follow this example below:
Private Sub CommandButton1_Click()
Dim ws As Worksheet, ws1 As Worksheet
Set ws = Sheets("KeyInformation")
Set ws1 = Sheets("Factsheet")
ws.Range("A2:Q2").Copy
ws1.Range("B9").PasteSpecial Paste:=xlPasteAll, Transpose:=True
Application.CutCopyMode = False
ws1.Activate
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.