Telling VBA to use a previously selected cell

curdman

New Member
Joined
Feb 20, 2014
Messages
1
Hi,
So what I am doing is pasting in data from another program. I want to write a macro to take that data, put each piece of data and put it in its own cell, then delete the first column. The issue is I can't get VBA to do this and put the data in the same spot it was. Every thing I have tried ends up with the data in the same spot, say cell B2, so it keeps writing over my previous data. I have included what I have so far. I select the data, then hit run and VBA moves it to a section I will keep empty, puts the data into individual cells, moves it back over (this is the problem) and deletes the first column of data. The moving it back over is where I want it to move it back to where it started not to a permanently specified cell...or I not have to move it in the first place (had trouble before this idea). When I didn't move it, the act of putting it into columns using VBA sent it to a specified place again, not the place it started.
Selection.Cut
Range("Q2").Select
ActiveSheet.Paste
Selection.TextToColumns Destination:=Range("Q2"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(6, 1), Array(11, 1), Array(25, 1), Array(37, 1))
Range("R2:U16").Select
Selection.Cut
Range("B2").Select
ActiveSheet.Paste
Range("Q2:Q16").Select
Selection.ClearContents
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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