Dellete column F all the values that dont have 3 digits

Excelnewbie001

Board Regular
Joined
Jan 25, 2017
Messages
79
Hope someone can help I am looking for a macro to delete all the values in colum F that dont have 3 digits. here is a sample data so in this sample below 1,3, must be deleted 2,,2 must be deleted. 4,, must be deleted. So only Numbers with 3 digits must not be deleted.Thanks for any help -this must be simple for vba programmer

1, 2, 1
1, 3,
1, 3, 0
2, , 2
2, 2, 0
2, 1, 1
3, , 1
3, 1, 0
4, ,
4, , 0
4, 0, 0
, , 4
, 4, 0
 
Last edited:
Thank you Rick for posting this also works
:huh: Does it?

Apart from the additional requirement introduced, which has not been addressed, it doesn't produce the same elimination results on the sample data as mine, so one of us must be wrong. :confused:
I'm guessing that the difference in the results relates the second piece of data posted by the OP (1, 3, )
It has CHAR(160) at the end which Rick's code does not pick-up.
(The code I posted works on the data posted - but presumably would not if there were two CHAR(160)'s at the end of the 1, 3, )
Yes, I think footoo might be correct... I saw that single occurrence of the non-breaking space (ASCII 160) and corrected it to a normal space figuring it was an anomaly caused by the way the OP copied his data into the thread. I figured the OP would write back and tell me my code did not work if there were actually non-breaking spaces in his data (at which point I would have modified my code with a SUBSTITUTE function call inside the Evaluate function call to convert non-breaking spaces to real spaces).
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Upvote 0
Peter - I meant that quick basic style coding might be more understandable to the OP than coding as below

Sub Del_Values_v2()
Dim a As Variant, b As Variant
Dim i As Long, k As Long

a = Range("F1", Range("F" & Rows.Count).End(xlUp)).Value
ReDim b(1 To UBound(a), 1 To 1)
For i = 1 To UBound(a)
If a(i, 1) Like "#, #, #" Then
k = k + 1
b(k, 1) = a(i, 1)
End If
Next i
Range("F1").Resize(UBound(b)).Value = b
End Sub

I do not know of course.....
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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