VBA copy button issues

ChrisMcIntyre

New Member
Joined
Jan 6, 2022
Messages
37
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi there!

I have a worksheet that needs to include two "copy" buttons that trigger macros to copy the text in the adjacent cells.

Issue #1
J2 has this formula =CONCATENATE(J1,TEXT(K1,"hhmmss")) that displays just nicely the text I need

1649152039350.png


but when I copy the cell I have a huge gap/space appear after the text, is there anyway to remove that so when I paste it's just the text?

Here's how it looks when I paste into Notepad, I've highlighted so you can see the entire pasted info

1649152699331.png


This is my super basic code so far...

Sub COPYPLANNUMBER()
Range("J2").Select
Selection.Copy
End Sub

Issue #2
H3 has this formula =AONG!E2 (just references some text on another sheet).

1649152467693.png


When my macro copies the cell I again have a huge gap/space appear after the text, is there anyway to remove that so when I paste it's just the text?

Here's how it looks when I paste into Notepad, I've highlighted so you can see the entire pasted info

1649152635416.png


The super basic code so far...

Sub COPYORDERNAME()
Range("H3").Select
Selection.Copy
End Sub
 
You're an absolute legend, that code worked. I tweaked it slightly from Z2 to L2 for the Plan Number and L3 for the Order Name, and it pasted just perfectly!

Thanks so much Joe4, really appreaciate that.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You are welcome!

Not sure why it wasn't working the way you had it (it should), but at least we figured out a way to get past the issue (whatever it was!).
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

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