Macro won't work to delete blank spaces

dilleyo725

Board Regular
Joined
Jan 31, 2006
Messages
65
Hello,

I'm trying to run a macro to delete blank values before and after data that I copied (from our online system) and pasted into excel, however it will not work. I've tested on values that I've manually entered in and put spaces before and after and it seems to run fine, which leads me to believe that the code works fine. Is there something in the data from copying from the web and pasting into excel that's causing the problem?

I also tried clearing all formats and also tried using a trim function but still no luck.

Also, does anyone have a macro to remove blank spaces from uneven data strings?
I appreciate any help on this.

edit: I just tested it on my computer at home, using Excel 2007, and it seems to be working. Would the macro code be different for different versions of excel?
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I use this one to delete empty rows<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
you might want to play around this one<o:p></o:p>
<o:p></o:p>
Sub Delete()
Dim a As Long
For a = Cells(Rows.Count, 5).End(xlUp).Row To 1 Step -1
If InStr(Cells(a, 5), "") = 0 Then
Rows(a).EntireRow.Delete
End If
Next a
End Sub<o:p></o:p>

<o:p> </o:p>
FYI<o:p></o:p>
it looks in the 5th column and if the cell is empty in that column it deletes the complete row<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

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