Copy cell and paste to a dynamic range in another worksheet

Dokat

Active Member
Joined
Jan 19, 2015
Messages
304
Office Version
  1. 365
Hi,

I have a file with multiple sheets. I would like to copy a cell from Sheet("Sta") cell:O18 and paste it to sheet "Summary" column D, but range will be based on first row and last row of column "C". In attached example "Sta" cell O18 (Test) is copied to column D3 through D18 based on the first and last row of column C. This range going to be dynamic. Can this be done? and Appreciate any help with code.
 

Attachments

  • Test.png
    Test.png
    12.8 KB · Views: 13

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try This:
VBA Code:
Sub Paste_Me()
'Modified  2/16/2022  6:24:33 AM  EST
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Sheets("Summary").Cells(Rows.Count, "C").End(xlUp).Row
Dim ans As String
ans = Sheets("Sta").Range("O18").Value
With Sheets("Summary")
    For i = 1 To Lastrow
        If .Cells(i, 3).Value <> "" Then .Cells(i, 4).Value = ans
Next
End With

Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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