Copy selection range and paste in a specific sheet

Unexpc

Active Member
Joined
Nov 12, 2020
Messages
496
Office Version
  1. 2019
Platform
  1. Windows
Hi guys
i want when i select a range, after that with run a macro, doing this 3 steps
Paste in a sheet that named Sheet from cell A3
after that print from a sheet that named Print
after that clear contents from A3 until rows of sheet that named Sheet be ended...
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try this:
VBA Code:
Sub CopyPaste()
Dim ShP As Worksheet, Lr As Long, Lm As Long
Set ShP = Worksheets(Range("A3").Value)
Lr = Range("A" & Rows.Count).End(xlUp).Row
Lm = Application.WorksheetFunction.CountIf(Range("A3:A" & Lr), Range("A3")) + 2
Selection.Copy ShP.Range("A2")
Range("A3:A" & Lm).ClearContents
End Sub
 
Upvote 0
Try this:
VBA Code:
Sub CopyPaste()
Dim ShP As Worksheet, Lr As Long, Lm As Long
Set ShP = Worksheets(Range("A3").Value)
Lr = Range("A" & Rows.Count).End(xlUp).Row
Lm = Application.WorksheetFunction.CountIf(Range("A3:A" & Lr), Range("A3")) + 2
Selection.Copy ShP.Range("A2")
Range("A3:A" & Lm).ClearContents
End Sub
Show error (Subscript out of range) i have tested it in a sheet that named Work & another sheet that named Paper
i want doing this function
Copy selection range from any sheet
Paste just in specific sheet that named Sheet
Print from specific sheet that named Print
Clear Contents A3:excel rows end in that specific sheet that named Sheet
 
Upvote 0
and another thing i have a colored cell plus in selection range and i want copy this cell and paste in specific cell in Sheet(for example in G2)...
 
Upvote 0
Please upload exact code you used.
Are your sheet name is exact the cell value at A3? & it doesn't have extra space
 
Upvote 0
Please upload exact code you used.
Are your sheet name is exact the cell value at A3? & it doesn't have extra space
i use your code
please see this, for step 1 (Copy/Paste)
 

Attachments

  • Screenshot 2021-03-04 143441.jpg
    Screenshot 2021-03-04 143441.jpg
    93.4 KB · Views: 12
  • Screenshot 2021-03-04 143513.jpg
    Screenshot 2021-03-04 143513.jpg
    85.4 KB · Views: 12
  • Screenshot 2021-03-04 144306.jpg
    Screenshot 2021-03-04 144306.jpg
    60.7 KB · Views: 12
Upvote 0
Please upload exact code you used.
And I don't see your sheet name that you wanted at cell A3 also.
 
Upvote 0
Please upload exact code you used.
And I don't see your sheet name that you wanted at cell A3 also.
The sheet added after that i take 2 photos, sorry i was wrong, i forgot added this sheet until i took screenshot (Photo3). you think the workbook have 3 sheet (Work-Sheet-Print)
i use your code with nothing change... what am i do?
 
Upvote 0
1. add sheetname that you want code run to it to Cell A3 at Activesheet(where macro Run)
2. I don't Know what is exact color code you used at your sheet. what is your one cell always has that color to I take color code from that cell.
 
Upvote 0
1. add sheetname that you want code run to it to Cell A3 at Activesheet(where macro Run)
2. I don't Know what is exact color code you used at your sheet. what is your one cell always has that color to I take color code from that cell.
1. i don't know i thing i doing wrong, please say how can i do this
2. color code: #70AD47
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,877
Members
449,130
Latest member
lolasmith

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