VBA Cut partial content/paste function

jweasl

New Member
Joined
Dec 31, 2013
Messages
8
Ok I've got it mostly figured out (I thought), but Excel doesn't like something about the code. I'm using Office 2010. When it tries to run the second line of this code, I get a 438 error:

Code:

Selection.Characters(83, Len(Selection) - 82).Cut</pre>
2qlzbpd.png


I'm guessing that Cut isn't an allowed method - but I'm not having any luck finding a list of operations I can use anywhere...
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Ok I've got it mostly figured out (I thought), but Excel doesn't like something about the code. I'm using Office 2010. When it tries to run the second line of this code, I get a 438 error:

Code:

Selection.Characters(83, Len(Selection) - 82).Cut
</PRE>
2qlzbpd.png


I'm guessing that Cut isn't an allowed method - but I'm not having any luck finding a list of operations I can use anywhere...

It is telling you that the Characters object does not support the Cut method. What you can do use the Left or Right functions to get your data moved to the destination cell, then use the Characters object to delete the unwanted portion of the text.
 
Upvote 0
I don't want to delete any text, I just want to move excess text to another cell. I'm trying to make it so the users don't have to manually move the content.
 
Upvote 0
The idea is to use eithe Left() or Right() functions to capture the text you want to move from the source cell. Put that in the destination cell. Then delete that same text from the source cell using the Characters method to deleted partial strings.
Code:
Dim src As Range, dst As Range
Set src = Range("A1")
Set dst = Range("A2")
dst = Left(src.Value, 5)
src.Characters(1, 5).Delete

It is the same effect as cutting and pasting.
 
Upvote 0
Ok, looks like that's the right path. Can you point me to any instructions on how to get it to work? I'm changing values with no luck, and I found a really long article on working with Ranges that I'm reading through, no luck yet there either.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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