VBA for Copy / Paste / Paste Special Blanks

ahennema

New Member
Joined
Sep 14, 2005
Messages
34
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to write a VBA macro where I can put my cursor in a cell at the top of a range of cells, where the number of rows can vary each time, and select the list of cells and then copy them to the adjoining row. When that is done I want to return to my original list and copy them again and use Paste Special Values to replace the formulas with just the cell values.

I am able to code the first part which is to select each row until a blank is found. I can then do the copy.

Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

How can I select the adjoining column and do the Copy and then do a Paste Special Values over the original selection?


Excel 2007 on Windows machine

Thanks, Arich
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
assuming dat in column A

tryk this macro



Code:
Sub test()
Dim r As Range
Set r = Range(Selection, Selection.End(xlDown))
r.Copy Selection.Offset(0, 1)
r.Copy
Selection.PasteSpecial xlPasteValues


End Sub

no empty cell in between.
y;ou waill lose the formula in original data
 
Upvote 0
Thank You!

That worked for me. I have had computer issues for the last week or two and have not been able to get back online to read the answers. I am back now. Once again thank you, your solution works for me.

Arich
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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