• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Paste as values and move to next empty cell

fareedexcel

Member
Dear Experts,

I have a table where by entering a number, data will auto populate.

Now the requirement is by clicking a button, those data to be pasted as values in another cell.

Then when entering the next number and clicking the button, the new data to be pasted in the next empty cells. Please help.

This is the code I used to paste the data from the auto populated cell,

Code:
Sub Pastecellvalues()
'Set the cells' values equal to another to paste values

    'Set a cell's value equal to another cell's value
Sheets("Data Capture").Range("B1").Copy
Sheets("Data Capture").Range("G4").End(xlUp).Offset(2, 0).PasteSpecial Paste:=xlPasteValues
Sheets("Data Capture").Range("B2").Copy
Sheets("Data Capture").Range("H4").End(xlUp).Offset(2, 0).PasteSpecial Paste:=xlPasteValues
Sheets("Data Capture").Range("B7").Copy
Sheets("Data Capture").Range("I4").End(xlUp).Offset(2, 0).PasteSpecial Paste:=xlPasteValues
Sheets("Data Capture").Range("B8").Copy
Sheets("Data Capture").Range("J4").End(xlUp).Offset(2, 0).PasteSpecial Paste:=xlPasteValues
Sheets("Data Capture").Range("B9").Copy
Sheets("Data Capture").Range("K4").End(xlUp).Offset(2, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
       
End Sub
 

Attachments

  • Paste as Values move to next cell.xlsx
    10.4 KB · Views: 3
According to initial explanation & attachment :​
Code:
Cells(Rows.Count, 7).End(xlUp)(2).Resize(, 5).Value = Application.Index([B1:B9], [{1,2,7,8,9}])

Incredible!!
giphy-downsized.gif
 
Hi Ashwin,

In the VBA code you have mentioned with the Offset rule, what if I need to paste a particular value to a particular cell instead of moving to the next blank cell.

Code:
Sub copypasvalue()


ActiveSheet.Range("D8").Copy
ActiveSheet.Cells(ActiveSheet.Rows.Count, "D").End(xlUp).Offset(1).PasteSpecial xlPasteValues

Application.CutCopyMode = False


End Sub

I need to paste the D8 value in D11 for example not in the next blank row.
 
Hi Ashwin,

In the VBA code you have mentioned with the Offset rule, what if I need to paste a particular value to a particular cell instead of moving to the next blank cell.

Code:
Sub copypasvalue()


ActiveSheet.Range("D8").Copy
ActiveSheet.Cells(ActiveSheet.Rows.Count, "D").End(xlUp).Offset(1).PasteSpecial xlPasteValues

Application.CutCopyMode = False


End Sub

I need to paste the D8 value in D11 for example not in the next blank row.
Follow Marc L response.

[D11].Value = [D8].Value
 
Back
Top