Copy and paste a cell value into next empty cell of a range

nbuddhi

New Member
Joined
Jun 23, 2020
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Dear Team,

I need to copy the value of V80 into next empty cell of range A80:A89. Could you please help me to specify the cell range A80:A89 with below code or new code.

VBA Code:
Private Sub CBCoppysummary_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Test Report")
Set pasteSheet = Worksheets("Test Report")

copySheet.Range("V80").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Thanks & Best Rgds,
Nuwan.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
What should happen if there are no blank cells in A80:A89?
 
Upvote 0
Are you saying that there will always be at least blank in that range?
 
Upvote 0
In that case try
VBA Code:
Private Sub CBCoppysummary_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Test Report")
Set pasteSheet = Worksheets("Test Report")

pasteSheet.Range("A80:A89").SpecialCells(xlBlanks)(1).Value = copySheet.Range("V80").Value
Application.ScreenUpdating = True
End Sub
Although I'm not sure why you are using two variables for the same worksheet
 
Upvote 0
Solution
In that case try
VBA Code:
Private Sub CBCoppysummary_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Test Report")
Set pasteSheet = Worksheets("Test Report")

pasteSheet.Range("A80:A89").SpecialCells(xlBlanks)(1).Value = copySheet.Range("V80").Value
Application.ScreenUpdating = True
End Sub
Although I'm not sure why you are using two variables for the same worksheet
Thank you very much Fluff. It worked like a charm. Actually I'm using same code for different sheets as well. Thanks again
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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