Removing dashes when importing text

kevbot_5000

New Member
Joined
Feb 19, 2015
Messages
2
First time poster, long time lurker. I'm importing data from a text file, but every now and then there is a "----" in the middle of my data which creates an extra column. This throws off the rest of my formulas. Any suggestions??
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hey Kev,

Is it always in the same column, and is it always the same number of dashes (4)?
 
Upvote 0
Thanks for the reply.

No, the data changes everyday. Sometimes there are dashes, sometimes there are none. I'm using VBA to import the data and was hoping that there was a way to ignore the dashes upon import.
 
Upvote 0
You could try something like this by selecting the top cell of any column that has the dashes in:

Code:
Sub remove_dashes()
    Application.ScreenUpdating = False
    Do Until ActiveCell.Value = "" 'go to the bottom of the column
    
        If ActiveCell.Value = "----" Then
            ActiveCell.Delete Shift:=xlToLeft
        End If
        ActiveCell.Offset(1).Activate
    Loop

    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,426
Messages
6,124,828
Members
449,190
Latest member
rscraig11

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