How to Add "Skip if Len <2" to VBA Code That Converts CSV to New Rows

MrBartlett

New Member
Joined
Jul 22, 2018
Messages
25
Hi all,

Below is my code:

Code:
Sub RedistributeCommaDelimitedData()
    Dim xArr() As String
    Dim xAddress As String
    Dim Rg As Range
    Dim Rg1 As Range
    On Error Resume Next
    xAddress = Application.ActiveWindow.RangeSelection.Address
    Set Rg = Application.InputBox("please select the data range:", xAddress, , , , , 8)
    If Rg Is Nothing Then Exit Sub
    Set Rg = Application.Intersect(Rg, Rg.Parent.UsedRange)
    If Rg Is Nothing Then Exit Sub
    Set Rg1 = Application.InputBox("please select output cell:", , , , , , 8)
    If Rg1 Is Nothing Then Exit Sub
    xArr = Split(Join(Application.Transpose(Rg.Value), ","), ",")
    Rg1.Resize(UBound(xArr) + 1) = Application.Transpose(xArr)
    Rg1.Parent.Activate
    Rg1.Resize(UBound(xArr) + 1).Select
End Sub

What's the best way to have it skip values that have length <2?

Thanks!
 

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.
You might receive more responses if you explained what you want to happen with your worksheet (explain in detail) instead of asking someone to change your code which is designed to do something very specific. New code may be a better option versus trying to band aid existing code. To offer this, a clear understanding of your workbook and what is happening would be a good start.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

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