Remove extra line when pasting copied cell into database

Mike TheSpike

New Member
Joined
Jul 12, 2021
Messages
40
Office Version
  1. 2010
Platform
  1. Windows
Hi All,

I need help guys, I want to eliminate extra step by not using backspace just to remove extra line(space) every time I paste a copied cell from excel into database or like in notepad just for example below.
space.PNG


Many Thanks,
Mike
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
There is linefeed or line break there to be removed, I'm just guessing. the character probably Chr(10)

I guess you are using macro recorder to write code. It is not efficient way but will work. Avoid if possible using Select.

Say I want to copy D2 to E7. Then use Replace to remove the line break

VBA Code:
Range("D2").Copy Range("E7")
Range("E7") = Replace(Range("E7"), Chr(10), "")
 
Upvote 0
There is linefeed or line break there to be removed, I'm just guessing. the character probably Chr(10)

I guess you are using macro recorder to write code. It is not efficient way but will work. Avoid if possible using Select.

Say I want to copy D2 to E7. Then use Replace to remove the line break

VBA Code:
Range("D2").Copy Range("E7")
Range("E7") = Replace(Range("E7"), Chr(10), "")
Hi Zot
I tried your code however i need to copy again the E7 which should be pasted into the database or like in notepad wherein there is always an extra line break(space) after pasting the copied cell.
Thanks for the feedback of the code using Select
 
Upvote 0

Forum statistics

Threads
1,223,365
Messages
6,171,654
Members
452,415
Latest member
mansoorali

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